Break through in 3 minutes. Try everything.
A, B, C, D = map(int, input().split())
s = sum([A, B, C, D])
for x in [A, B, C, D, A + B, A + C, A + D, B + C, B + D, C + D]:
if x == s - x:
print('Yes')
break
else:
print('No')
It breaks through in 10 minutes. Needless to say, if you simulate it naively, even if you can retrieve the maximum value at high speed with a priority queue, TLE desperately when the minimum value is x = 1. Is it a demon that TLEs even if it is simulated?
If you realize that this calculation is actually a problem to find the greatest common divisor, you can solve it with the following.
from math import gcd
from functools import reduce
N, *a = map(int, open(0).read().split())
print(reduce(gcd, a))
Lost. About 10 minutes before the end, the input / output example passed and I thought "I did it!", But about half of it was WA and TLE ...
Recommended Posts