Codechef Long challenge
JULY 2020
PROBLEM - Chef and Card Game (CRDGAME)
PROBLEM DESCRIPTION

Example
Array size = 3
10 4
8 12
7 6
Example
Array size = 3
10 4
8 12
7 6
1 4
8 3
7 6
Example
Array size = 3
10 4
8 12
7 6
1 4
8 3
7 6
| Chef | Morty |
|---|---|
| 0 | 1 |
| 1 | 1 |
| 2 | 1 |
Chef will win and points he scored will be 2.
Approach :
struct point{
int a = 0;
int b = 0;
};
int main()
{
int t;
cin >> t;
while(t--)
{
int n;
cin >> n;
point* game = new point[n];
int neta = 0;
int netb = 0;
for(int i =0; i<n; i++)
{
long long int alpha,beta;
cin >> alpha;
cin >> beta;
while(alpha > 0)
{
int g = alpha%10;
alpha /=10;
game[i].a += g;
}
while(beta > 0)
{
int g = beta%10;
beta /=10;
game[i].b += g;
}
if(game[i].a > game[i].b)
neta++;
else if(game[i].a == game[i].b)
{
neta++;
netb++;
}
else
netb++;
}
if(neta > netb)
{
cout << "0" << " " << neta << endl;
}
else if(netb > neta)
{
cout << "1" << " " << netb << endl;
}
else
{
cout << "2" << " " << neta << endl;
}
}
return 0;
}Still, Have any Doubts???
Still, Have any Doubts???
Comment it You will get a reply
OR
Send your doubt to email provided in description.
Copy of Copy of Copy of Codechef Cook off
By Chirayu Jain
Copy of Copy of Copy of Codechef Cook off
- 82