Treasure Hunt CodeChef Code-O-Fiesta solution Python
Treasure Hunt Editorial and Solutions
PROBLEM STATEMENT
Two friends Ron and Harry went to take part in a game called treasure hunt. There are N levels in the game. In each level ‘i’, Ci numbers of coins of the same value are hidden. Ron is happy if he has strictly more coins than Harry. However, Harry is happy only if the difference between their number of coins is not more than 1. They agree to help each other by collecting the coins in such a way that makes both of them happy. Write a code to output “YES” if there is a possibility of both of them being happy after playing the game; otherwise output “NO”.
UNDERSTANDING THE PROBLEM:
PYTHON 3 CODE:
1 2 3 4 5 6 7 8 9 10 | n =int(input()) a = input() lst = a.split(" ") sum =0 for item in lst: sum+=int(item) if sum%2 == 0: print("NO") else: print("YES") |
Comments
Post a Comment