Chef and Contest: CHEFCONTEST

                     

Contributor: Priya (CSE)

link: https://www.codechef.com/CU1PP0008/problems/CHEFCONTEST

Chef and Chefina are competing against each other in a programming contest. They were both able to solve all the problems in the contest, so the winner between them must be decided by time penalty. Chef solved all the problems in X minutes and made P wrong submissions, while Chefina solved all the problems in Y minutes and made Q wrong submissions. Who won the competition (or was it a draw)?

Note: The time penalty is calculated as follows:

The base time penalty is the time at which the final problem was solved (so, X for Chef and Y for Chefina)
Each wrong submission adds a penalty of 10 minutes
The winner is the person with less penalty time. If they both have the same penalty, it is considered a draw.
Input Format
The first line of input contains a single integer T, denoting the number of test cases. The description of T test cases follows.
The first and only line of each test case contains four space-separated integers — X,Y,P, and Q respectively.
Output Format
For each test case, output a single line containing one string — the name of the winner (“Chef” or “Chefina”), or “Draw” if the match was a draw. Print each string without the quotes.

Each character of the answer can be printed in either uppercase or lowercase, i.e, the strings “Chef”, “chEf”, “cHeF”, etc. are treated as equivalent.

Constraints
1≤T≤1000
1≤X,Y≤100
0≤P,Q≤100
Sample Input 1
3
10 8 2 3
10 10 10 10
40 21 2 0
Sample Output 1
Chef
Draw
Chefina
Explanation
Test Case 1:

Chef solved the problems in 10 minutes and made 2 wrong submissions, thus his total penalty is 10+2⋅10=30 minutes.
Chefina solved the problems in 8 minutes and made 3 wrong submissions, thus her total penalty is 8+3⋅10=38 minutes.
Chef took less time, so he is the winner.

Test Case 2:

Chef solved the problems in 10 minutes and made 10 wrong submissions, thus his total penalty is 10+10⋅10=110 minutes.
Chefina solved the problems in 10 minutes and made 3 wrong submissions, thus her total penalty is 10+10⋅10=110 minutes.
Chef and Chefina took the same time, so the match is a draw.

Test Case 3:

Chef solved the problems in 40 minutes and made 2 wrong submissions, thus his total penalty is 40+2⋅10=60 minutes.
Chefina solved the problems in 21 minutes and made 0 wrong submissions, thus her total penalty is 21+0⋅10=21 minutes.
Chefina took less time, so she is the winner.

Solution:

#include <iostream>
using namespace std;

int main() {
    int t;
    cin>>t;
    while(t--){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        int ans1=a+c*10;
        int ans2=b+d*10;
        if(ans1<ans2){
            cout<<"Chef"<<endl;
        }
        else if(ans1==ans2)
            cout<<"Draw"<<endl;
        else
            cout<<"Chefina"<<endl;
  }
	return 0;
}

* The material and content uploaded on this website are for general information and reference purposes only. Please do it by your own first.