304 North Cardinal St.
Dorchester Center, MA 02124

# Olympics Ranking CodeChef Solution – Queslers

## Problem: Olympics Ranking CodeChef Solution

In Olympics, the countries are ranked by the total number of medals won. You are given six integers G1G1, S1S1, B1B1, and G2G2, S2S2, B2B2, the number of gold, silver and bronze medals won by two different countries respectively. Determine which country is ranked better on the leaderboard. It is guaranteed that there will not be a tie between the two countries.

### Input Format

• The first line of the input contains a single integer TT denoting the number of test cases. The description of TT test cases follows.
• The first and only line of each test case contains six space-separated integers G1G1, S1S1, B1B1, and G2G2, S2S2, B2B2.

### Output Format

For each test case, print `"1"` if the first country is ranked better or `"2"` otherwise. Output the answer without quotes.

### Constraints

• 1≤T≤10001≤T≤1000
• 0≤G1,S1,B1,G2,S2,B2≤30

Subtask #1 (100 points): Original constraints

#### Sample Input 1

``````3
10 20 30 0 29 30
0 0 0 0 0 1
1 1 1 0 0 0``````

#### Sample Output 1

``````1
2
1``````

### Explanation

Test case 11: Total medals for the first country are 10+20+30=6010+20+30=60 and that for the second country are 0+29+30=590+29+30=59. So the first country is ranked better than the second country.

Test case 22: Total medals for the first country are 0+0+0=00+0+0=0 and that for the second country are 0+0+1=10+0+1=1. So the second country is ranked better than the first country.

## Olympics Ranking CodeChef Solution Using C

``````#include <stdio.h>

int main(void) {
int p;
int T;
scanf("%d",&T);
while(T--)
{
for(int i=0;i<6;i++)
{
scanf("%d",&p[i]);
}
int s1=p+p+p;
int s2=p+p+p;
if(s1>s2)
printf("\n1");
else
printf("\n2");
}
}``````

## Olympics Ranking CodeChef Solution Using Python

``````# cook your dish here
for i in range(int(input())):
a=list(map(int,input().split()))
#rint(a[:2])
if sum(a[:3])>sum(a[3:]):
print(1)
else:print(2)
``````

## Olympics Ranking CodeChef Solution Using Java

``````/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int T=sc.nextInt();
for(int i=0;i<T;i++){
int[] a=new int;
int country1=0,country2=0;
for(int j=0;j<6;j++){
a[j]=sc.nextInt();
if(j<3){
country1=country1+a[j];}
else{
country2=country2+a[j];
}
}
if(country1>country2){
System.out.println("1");
}
else{
System.out.println("2");
}

}
}
}
``````

## Olympics Ranking CodeChef Solution Using C++

``````#include <bits/stdc++.h>
using namespace std;

int main() {
int t;
cin>>t;
while(t--)
{
int a1,b1,c1,a2,b2,c2;
cin>>a1>>b1>>c1>>a2>>b2>>c2;
if((a1+b1+c1)>(a2+b2+c2))
{
cout<<"1"<<"\n";
}
else
{
cout<<"2"<<"\n";
}
}

}``````
##### Olympics Ranking CodeChef Solution Review:

In our experience, we suggest you solve this Olympics Ranking CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

Olympics Ranking Problem is available on Hacker Rank for Free, if you are stuck anywhere between a compilation, just visit Queslers to get Olympics Ranking CodeChef Solution.

##### Conclusion:

I hope this Olympics Ranking CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Hacker Rank, Leetcode, Codechef, Codeforce Solution.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Hacker Rank Problem & Solutions >>

Staircase Hacker Rank Solution

A Very Big Sum Hacker Rank Solution

Diagonal Difference Hacker Rank Solution

Nested Lists Hacker Rank Solution

Lists Hacker Rank Solution

More CodeChef Solutions >>

Olympics Ranking CodeChef Solution

Problem Difficulties CodeChef Solution