# CHEFCONTEST - Editorial

Author: Utkarsh Gupta
Tester: Abhinav Sharma and Lavish Gupta
Editorialist: Nishank Suresh

Cakewalk

None

# PROBLEM:

Chef solved all the problems of a contest in X minutes with P wrong submissions, while Chefina took Y minutes and made Q wrong submissions. Each wrong submission adds 10 minutes to the total penalty. Who did better?

# EXPLANATION:

Chef and Chefina both solved every problem, so we simply need to compare their total penalty times to find out who did better. Each wrong submission adds 10 minutes to penalty time. So,

• Chef’s total penalty is X + 10\cdot P minutes
• Chefina’s total penalty is Y + 10\cdot Q minutes

Simply compute these two numbers and compare them to find out who won, or if it was a draw. In most languages, this is a direct application of if conditions, with pseudocode looking something like this:

if x + 10*p < y + 10*q
Chef wins
else if x + 10*p > y + 10*q:
Chefina wins
else
Draw


# TIME COMPLEXITY:

\mathcal{O}(1) per testcase.

# SOLUTIONS:

Setter's Solution (C++)
#include <bits/stdc++.h>
using namespace std;

/*
------------------------Input Checker----------------------------------
*/

long long readInt(long long l,long long r,char endd){
long long x=0;
int cnt=0;
int fi=-1;
bool is_neg=false;
while(true){
char g=getchar();
if(g=='-'){
assert(fi==-1);
is_neg=true;
continue;
}
if('0'<=g && g<='9'){
x*=10;
x+=g-'0';
if(cnt==0){
fi=g-'0';
}
cnt++;
assert(fi!=0 || cnt==1);
assert(fi!=0 || is_neg==false);

assert(!(cnt>19 || ( cnt==19 && fi>1) ));
} else if(g==endd){
if(is_neg){
x= -x;
}

if(!(l <= x && x <= r))
{
cerr << l << ' ' << r << ' ' << x << '\n';
assert(1 == 0);
}

return x;
} else {
assert(false);
}
}
}
string ret="";
int cnt=0;
while(true){
char g=getchar();
assert(g!=-1);
if(g==endd){
break;
}
cnt++;
ret+=g;
}
assert(l<=cnt && cnt<=r);
return ret;
}
long long readIntSp(long long l,long long r){
}
long long readIntLn(long long l,long long r){
}
}
}

/*
------------------------Main code starts here----------------------------------
*/

const int MAX_T = 1e5;
const int MAX_N = 1e5;
const int MAX_SUM_LEN = 1e5;

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define mp make_pair
#define ll long long

int sum_len = 0;
int max_n = 0;
int yess = 0;
int nos = 0;
int total_ops = 0;

const ll MX=200000;
ll fac[MX], ifac[MX];

const ll mod = 998244353;

ll po(ll x, ll n ){
ll ans=1;
while(n>0){
if(n&1) ans=(ans*x)%mod;
x=(x*x)%mod;
n/=2;
}
return ans;
}

void solve()
{

int x,y,p,q;

int t1 = x+10*p;
int t2 = y+10*q;

if(t1<t2) cout<<"CheF";
else if(t1==t2) cout<<"dRaW";
else cout<<"CheFiNA";

cout<<'\n';

}

signed main()
{

#ifndef ONLINE_JUDGE
freopen("input.txt", "r" , stdin);
freopen("output.txt", "w" , stdout);
#endif
fast;

int t = 1;

for(int i=1;i<=t;i++)
{
solve();
}

assert(getchar() == -1);

cerr<<"SUCCESS\n";
cerr<<"Tests : " << t << '\n';
cerr<<"Sum of lengths : " << sum_len << '\n';
cerr<<"Maximum length : " << max_n << '\n';
// cerr<<"Total operations : " << total_ops << '\n';
//cerr<<"Answered yes : " << yess << '\n';
//cerr<<"Answered no : " << nos << '\n';
}

Tester's Solution (C++)
#include <bits/stdc++.h>
using namespace std;
#define ll long long

/*
------------------------Input Checker----------------------------------
*/

long long readInt(long long l,long long r,char endd){
long long x=0;
int cnt=0;
int fi=-1;
bool is_neg=false;
while(true){
char g=getchar();
if(g=='-'){
assert(fi==-1);
is_neg=true;
continue;
}
if('0'<=g && g<='9'){
x*=10;
x+=g-'0';
if(cnt==0){
fi=g-'0';
}
cnt++;
assert(fi!=0 || cnt==1);
assert(fi!=0 || is_neg==false);

assert(!(cnt>19 || ( cnt==19 && fi>1) ));
} else if(g==endd){
if(is_neg){
x= -x;
}

if(!(l <= x && x <= r))
{
cerr << l << ' ' << r << ' ' << x << '\n';
assert(1 == 0);
}

return x;
} else {
assert(false);
}
}
}
string ret="";
int cnt=0;
while(true){
char g=getchar();
assert(g!=-1);
if(g==endd){
break;
}
cnt++;
ret+=g;
}
assert(l<=cnt && cnt<=r);
return ret;
}
long long readIntSp(long long l,long long r){
}
long long readIntLn(long long l,long long r){
}
}
}

/*
------------------------Main code starts here----------------------------------
*/

const int MAX_T = 1000;
const int MAX_N = 100;
const int MAX_SUM_N = 100000;

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int sum_n = 0;
int max_n = 0;
int yess = 0;
int nos = 0;
int total_ops = 0;
ll z = 998244353;
ll dp[2500005] ;

void solve()
{
int x = readIntSp(1 , MAX_N) ;
int y = readIntSp(1 , MAX_N) ;
int p = readIntSp(0 , MAX_N) ;
int q = readIntLn(0 , MAX_N) ;

int pen1 = x + 10*p ;
int pen2 = y + 10*q ;

if(pen1 < pen2)
{
cout << "cHeF" << endl ;
return ;
}
if(pen1 != pen2)
{
cout << "cHefIna" << endl ;
}
else
cout << "dRaw" << endl ;
return ;

}

signed main()
{
// fast;
#ifndef ONLINE_JUDGE
freopen("inputf.txt" , "r" , stdin) ;
freopen("outputf.txt" , "w" , stdout) ;
freopen("error.txt" , "w" , stderr) ;
#endif

int t = 1;

for(int i=1;i<=t;i++)
{
solve() ;
}

assert(getchar() == -1);
cerr<<"SUCCESS\n";
cerr<<"Tests : " << t << '\n';
// cerr<<"Sum of lengths : " << sum_n << '\n';
// cerr<<"Maximum length : " << max_n << '\n';
// cerr<<"Total operations : " << total_ops << '\n';
// cerr<<"Answered yes : " << yess << '\n';
// cerr<<"Answered no : " << nos << '\n';
}

Editorialist's Solution (Python)
for _ in range(int(input())):
x, y, p, q = map(int, input().split())
if x + 10*p < y + 10*q:
print('Chef')
elif x + 10*p > y + 10*q:
print('Chefina')
else:
print('Draw')