Hello coders, today we are going to solve **Olympics Ranking** **CodeChef Solution** whose Problem Code is** OLYRANK**.

**Task**

In Olympics, the countries are ranked by the total number of medals won. You are given six integers ** G1**,

*,*

**S1***, and*

**B1***,*

**G2***,*

**S2***, the number of gold, silver and bronze medals won by two different counties respectively. Determine which country is ranked better on the leaderboard. It is guaranteed that there will not be a tie between the two countries.*

**B2****Input Format**

- The first line of the input contains a single integer
denoting the number of test cases. The description of*T*test cases follows.*T* - The first and only line of each test case contains six space-separated integers
,**G1**,**S1**, and**B1**,**G2**,**S2**.**B2**

**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*≤ 1000 **0 ≤***G1*,*S1*,*B1*,*G2*,*S2*,*B2*≤ 30

**Subtasks**

**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 1: **Total medals for the first country are **10+20+30=60** and that for the second country are **0+29+30=59**. So the first country is ranked better than the second country.

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

**Solution – Olympics Ranking**

**C++**

#include <iostream> using namespace std; int main() { // your code goes here int t ; cin >> t; while(t--){ int c1=0,c2=0; for(int i=0;i<3;i++){ int n; cin >> n; c1+=n; } for(int i=0;i<3;i++){ int n; cin >> n; c2+=n; } if(c1 > c2) cout << 1 << "\n"; else cout << 2 << "\n"; } return 0; }

**Python**

T = int(input()) for i in range(T): a, b, c, d, e, f = map(int, input().split()) first_country = a + b + c second_country = d + e + f if first_country > second_country: print(1) else: print(2)

**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 { // your code goes here Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0){ int c1 = 0,c2=0; for(int i=0;i<3;i++){ int n = sc.nextInt(); c1+=n; } for(int i=0;i<3;i++){ int n = sc.nextInt(); c2+=n; } if(c1 > c2){ System.out.println(1); }else{ System.out.println(2); } } } }

**Disclaimer:** The above Problem **(Olympics Ranking)** is generated by **CodeChef** but the Solutions are Provided by **CodingBroz**. This tutorial is only for **Educational **and **Learning** Purpose.