Cricket Ranking Codechef Solution

In a season, each player has three statistics: runs, wickets, and catches. Given the season stats of two players AA and BB, denoted by RR, WW, and CC respectively, the person who is better than the other in the most statistics is regarded as the better overall player. Tell who is better amongst AA and BB. It is known that in each statistic, the players have different values.

Input Format

  • The first line contains an integer TT, the number of test cases. Then the test cases follow.
  • Each test case contains two lines of input.
  • The first line contains three integers R1R1, W1W1, C1C1, the stats for player AA.
  • The second line contains three integers R2R2, W2W2, C2C2, the stats for player BB.

Output Format

For each test case, output in a single line "A" (without quotes) if player AA is better than player BB and "B" (without quotes) otherwise.

Constraints

  • 1≤T≤10001≤T≤1000
  • 0≤R1,R2≤5000≤R1,R2≤500
  • 0≤W1,W2≤200≤W1,W2≤20
  • 0≤C1,C2≤200≤C1,C2≤20
  • R1≠R2R1≠R2
  • W1≠W2W1≠W2
  • C1≠C2C1≠C2

Sample Input 1 

3
0 1 2
2 3 4
10 10 10
8 8 8
10 0 10
0 10 0

Sample Output 1 

B
A
A

Explanation

Test Case 11: Player BB is better than AA in all 33 fields.

Test Case 22: Player AA is better than BB in all 33 fields.

Test Case 33: Player AA is better than BB in runs scored and number of catches.

Cricket Ranking  – CodeChef Solution in JAVA

import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef_1
{
    public static void main (String[] args) throws java.lang.Exception
    {
        
        Scanner sc = new Scanner(System.in);
        int citizens = sc.nextInt();
        for(int z=0;z<citizens;z++){
          int a1=sc.nextInt(); int a2=sc.nextInt(); int a3=sc.nextInt();
         int b1=sc.nextInt(); int b2=sc.nextInt(); int b3=sc.nextInt();
         if(a1>b1 && a2>b2){
            System.out.println("A");
         }else if(a2>b2 && a3>b3){
            System.out.println("A"); 
         }else if(a1>b1 && a3>b3){
             System.out.println("A");
         }else{
             System.out.println("B");
         }}}}

Cricket Ranking – CodeChef Solution in CPP

#include<iostream>
using namespace std;

int main()
{
    int t;
    cin>>t;
    while(t--){
    int x,y,z,a,b,c;
    cin>>x>>y>>z>>a>>b>>c;
     int p=0;
     int q=0;
    
    if(x>a) p++;
     else q++;
    if(y>b) p++;
     else q++;
    if(z>c) p++;
     else q++;
    
    if(p>q)
     cout<<"A\n";
    else
     cout<<"B\n";
    }
    return 0;
}

Cricket Ranking -CodeChef Solution in Python

T = int(input())

for i in range(T):
    (r_a,w_a,c_a) = map(int,input().split())
    (r_b,w_b,c_b) = map(int,input().split())
    L =[]
    if(r_a>r_b):
        L.append('a')
    else:
        L.append('b')
    if(w_a>w_b):
        L.append('a')
    else:
        L.append('b')
    if(c_a>c_b):
        L.append('a')
    else:
        L.append('b')
    if(L.count('a')>L.count('b')):
        print('A')
    else:
        print('B')

Disclaimer: The above Problem (Cricket Ranking ) is generated by CodeChef but the solution is provided by Codeworld19.This tutorial is only for Educational and Learning purpose.

Leave a Reply

Your email address will not be published. Required fields are marked *