Man of the Match Codechef Solution || Codechef contest solution

,

In a cricket match, there are two teams, each comprising 1111 players. The scorecard of the match lists the runs scored and wickets taken by each of these 2222 players.

To determine the “Man of the Match”, we assess each player’s performance. Points are awarded to a player as follows:

  • Each run scored earns 11 point.
  • Every wicket taken earns 2020 points.

The player with the highest total points is awarded the “Man of the Match” title.

You are given the scorecard of a cricket match, listing the contributions of all 2222 players.
The players are numbered from 11 to 2222. Find the “Man of the Match”.
It is guaranteed that for all inputs to this problem, the “Man of the Match” is unique.

Note: A player who belongs to the losing team can also win the “Man of the Match” award.

Input Format

  • The first line of input will contain a single integer �T, denoting the number of test cases.
  • Each test case consists of 2222 lines of input. The �i-th of these 2222 lines contains two space-separated integers ��Ai​ and ��Bi​ — respectively, the runs scored and wickets taken by the �i-th player.

Output Format

For each test case, output on a new line a single integer �i (1≤�≤22)(1≤i≤22) denoting the index of the player with the maximum score.

The tests for this problem are designed such that there will be exactly one player with the maximum score.

Constraints

  • 1≤�≤10001≤T≤1000
  • 0≤�≤2000≤A≤200
  • 0≤�≤100≤B≤10
  • There will be exactly 11 player with the maximum score.
#include <bits/stdc++.h>
using namespace std;

int main() {
	// your code goes here
	int t;
	cin >> t;
	while (t>0) {
	    int n, m, high=0, res=0;
	    for (int i=1; i<23; i++) {
	        cin >> n >> m;
	        int temp = n + m*20;
	        if (temp>high) {
	            high=temp;
	            res=i;
	        }
	    }
	        cout << res << endl;
	    t--;
	}
}

Leave a Reply

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