Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Chefland is holding a virtual marathon for the categories 10 km, 21 km and 42 km having prizes A,B,C (A<B<C) respectively to promote physical fitness. In order to claim the prize in a particular category the person must cover the total distance for that category within D days. Also a single person cannot apply in multiple categories.
Given the maximum distance d km that Chef can cover in a single day, find the maximum prize that Chef can win at the end of D days. If Chef can’t win any prize, print 0.
###Input
###Output For each test case, output in a single line the answer to the problem.
###Constraints
Input:
3
1 1 1 2 3
10 1 1 2 3
10 3 1 2 3
Output:
0
1
2
Test Case 1: The maximum distance covered by Chef is 1⋅1=1 km which is less than any of the available distance categories. Hence Chef won’t be able to claim a prize in any of the categories.
Test Case 2: The maximum distance covered by Chef is 10⋅1=10 km which is equal to distance of the first category. Hence Chef can claim the maximum prize of 1 units.
Test Case 3: The maximum distance covered by Chef is 10⋅3=30 km which is more than the distance of the second category but less than that of the third category. Hence Chef can claim the maximum prize of 2 units.
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner in = new Scanner(System.in);
int t = in.nextInt();
while(t-- >0){
int D = in.nextInt();
int d = in.nextInt();
int a = in.nextInt();
int b = in.nextInt();
int c = in.nextInt();
int ans = (d*D);
if(ans>=0 &&ans<10){
System.out.println(0);
}else if(ans<21){
System.out.println(a);
}else if (ans<42) {
System.out.println(b);
}else{
System.out.println(c);
}
}
}
}
test_cases = int(input(" "))
for i in range (0,test_cases):
text = input(" ")
(D,d,a,b,c) = map(int,text.split(" "))
ran = D * d
if ran >= 0 and ran < 10:
print(0)
elif ran < 21:
print(a)
elif ran < 42:
print(b)
else:
print(c)
#include <iostream>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t--)
{
int D,d,A,B,C;
cin>>D>>d>>A>>B>>C;
if(d*D>=42)
cout<<C<<endl;
else if(d*D>=21)
cout<<B<<endl;
else if(d*D>=10)
cout<<A<<endl;
else
cout<<0<<endl;
}
return 0;
}
In our experience, we suggest you solve this Marathon CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
If you are stuck anywhere between any coding problem, just visit Queslers to get the Marathon CodeChef Solution
I hope this Marathon CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.
This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.
Keep Learning!
More Coding Solutions >>