Algorithm
Problem link: https://www.codechef.com/problems/GDTURN
Problem
Chef and Chefina are playing with dice. In one turn, both of them roll their dice at once.
They consider a turn to be good if the sum of the numbers on their dice is greater than .
Given that in a particular turn Chef and Chefina got and on their respective dice, find whether the turn was good.
Input Format
- The first line of input will contain a single integer , denoting the number of test cases.
- Each test case contains two space-separated integers and — the numbers Chef and Chefina got on their respective dice.
Output Format
For each test case, output on a new line, YES, if the turn was good and NO otherwise.
Each character of the output may be printed in either uppercase or lowercase. That is, the strings NO, no, nO, and No will be treated as equivalent.
Constraints
Sample 1:
4 1 4 3 4 4 2 2 6
NO YES NO YES
Explanation:
Test case : The sum of numbers on the dice is which is smaller than . Thus, the turn is not good.
Test case : The sum of numbers on the dice is which is greater than . Thus, the turn is good.
Test case : The sum of numbers on the dice is which is equal to . Thus, the turn is not good.
Test case : The sum of numbers on the dice is which is greater than . Thus, the turn is good.
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include<stdio.h>
int main()
{
int n,x,y;
scanf("%d",&n);
while(n--)
{
scanf("%d %d",&x,&y);
if(x+y>6) printf("YES\n");
else printf("NO\n");
}
}
Copy The Code &
Try With Live Editor
Input
1 4
3 4
4 2
2 6
Output
YES
NO
YES
Demonstration
CodeChef Solution - GDTURN-Good Turn