Skip to content

Commit 6686da9

Browse files
authored
Create Cricket_Ranking.c
1 parent 35615d4 commit 6686da9

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

Codechef Problems/Cricket_Ranking.c

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/* PROBLEM STATEMENT
2+
In a season, each player has three statistics: runs, wickets, and catches. Given the season stats of two players A and B, denoted by R, W, and C respectively,
3+
the person who is better than the other in the most statistics is regarded as the better overall player. Tell who is better amongst A and B. It is known that in each statistic,
4+
the players have different values.
5+
Input Format
6+
The first line contains an integer T, the number of test cases. Then the test cases follow.
7+
Each test case contains two lines of input.
8+
The first line contains three integers R1, W1, C1, the stats for player A.
9+
The second line contains three integers R2, W2, C2, the stats for player B.
10+
Output Format
11+
For each test case, output in a single line "A" (without quotes) if player A is better than player B and "B" (without quotes) otherwise.
12+
Constraints
13+
1≤T≤1000
14+
0≤R1,R2≤500
15+
0≤W1,W2≤20
16+
0≤C1,C2≤20
17+
R1≠R2
18+
W1≠W2
19+
C1≠C2
20+
Sample Input 1
21+
3
22+
0 1 2
23+
2 3 4
24+
10 10 10
25+
8 8 8
26+
10 0 10
27+
0 10 0
28+
Sample Output 1
29+
B
30+
A
31+
A
32+
Explanation
33+
Test Case 1: Player B is better than A in all 3 fields.
34+
Test Case 2: Player A is better than B in all 3 fields.
35+
Test Case 3: Player A is better than B in runs scored and number of catches. */
36+
37+
38+
#include <stdio.h>
39+
40+
int main(void) {
41+
int i=0;
42+
int tc;
43+
// tc is to take input the number of test cases
44+
scanf("%d",&tc);
45+
int a[tc];
46+
int t=tc;
47+
int r1,w1,c1,r2,w2,c2;
48+
while(tc--)
49+
{
50+
scanf("%d %d %d",&r1,&w1,&c1); //stores respective inputs for player A
51+
scanf("%d %d %d",&r2,&w2,&c2); //stores respective inputs for player B
52+
53+
if(((w1>w2)&&(r1>r2)&&(c1>c2))||((w1>w2)&&(c1>c2))||((c1>c2)&&(r1>r2))||((r1>r2)&&(w1>w2)))
54+
{
55+
a[i]=1; //stores 1 in the array for results favouring player A
56+
}
57+
else
58+
{
59+
a[i]=2; //stores 1 in the array for results favouring player B
60+
}
61+
i++;
62+
}
63+
64+
for(int j=0;j<t;j++)
65+
{
66+
if(a[j]==1)
67+
{
68+
printf("A \n");
69+
70+
}
71+
else
72+
{
73+
printf("B \n");
74+
}
75+
76+
}
77+
return 0;
78+
}

0 commit comments

Comments
 (0)