# TSTPROB - Editorial

Practice

Author: Ashraf Khan
Tester: Ashraf Khan
Editorialist: Ashraf Khan

CAKEWALK

# PREREQUISITES:

Math, Basic Programming

# PROBLEM:

Chef and his friend had appeared for a test whose results are out now. The test had N number of sections each of 20 marks. You are given the marks (M1 and M2) scored by both of them in respective sections of the test. Help Chef to find if he has scored more than his friend or not.

# QUICK EXPLANATION:

Sum-up Chef’s marks and then sum-up his friend’s marks and then compare them. If Chef’s total marks is greater than his friend’s total marks then print YES or else print NO.

# EXPLANATION

The very first line of input is the number of testcases (say T).
The very first line of each testcase contains the value of N, i.e. the number of sections in the test.
The following two lines contains N numbers, each representing the marks scored in that particular section of the test. The first line contains Chef’s marks and the second line contains his friend’s marks.

For example, consider the following demo testcase…
1
4
10 15 20 5
9 13 19 7

Here, the number of testcase is 1, value of N is 4, {10, 15, 20 & 5} are the marks scored by Chef and {9, 13, 19 & 7} are the marks scored by his friend.

Sum-up the marks scored by the Chef and store it in a variable (say marksOfChef) and then sum-up the marks scored by his friend and store it in a separate variable (say marksOfFriend). Then compare these two variables. If marksOfChef is greater than marksOfFriend then print YES or else print NO.

# SOLUTIONS:

Setter's Solution
``````#Solution code in Python3

#Taking input for Testcases
T = int(input())

while T>0:
T -= 1

#Taking input for the number of sections of the test for which Chef and his friend has appeared
N = int(input())

#Storing Chef's marks in list M1
M1 = list(map(int, input().split()))

#Storing Chef's friend's marks in list M2
M2 = list(map(int, input().split()))

#Summing-up and comparing the total marks
if(sum(M1) > sum(M2)):
print("YES")
else:
print("NO")
``````
Tester's Solution
``````//Solution code in C++

#include <iostream>
using namespace std;

int main() {
int T;
//Taking input for Testcases
cin >> T;

while(T--) {
int N;
//Taking input for the number of sections of the test for which Chef and his friend has appeared
cin >> N;

int M1, M2;
int total1 = 0, total2 = 0; //initially total marks of Chef and his friend is 0

//Taking Chef's marks in M1 one-by-one and summing them simultaneously
for(int i=0; i<N; i++) {
cin >> M1;
total1 = total1 + M1;
}

//Taking Chef's friend's marks in M2 one-by-one and summing them simultaneously
for(int i=0; i<N; i++) {
cin >> M2;
total2 = total2 + M2;
}

//Comparing total1 and total2
if(total1 > total2) {
cout << "YES" << endl;
}
else {
cout << "NO" << endl;
}
}
return 0;
}
``````
Editorialist's Solution
``````#Solution code in Python3

#Taking input for Testcases
T = int(input())

while T>0:
T -= 1

#Taking input for the number of sections of the test for which Chef and his friend has appeared
N = int(input())

#Storing Chef's marks in list M1
M1 = list(map(int, input().split()))

#Storing Chef's friend's marks in list M2
M2 = list(map(int, input().split()))

#Summing-up and comparing the total marks
if(sum(M1) > sum(M2)):
print("YES")
else:
print("NO")
``````