思路:思维题。首先特判0,如果有0存在直接返回False即可;然后计数判断元素种类,如果元素种类不为2,此时必然满足条件,返回True;如果元素种类确实只有两种,那再额外判断一下他们的和是否为0,如果是的话必然无法满足条件,反之满足条件
代码:
import sys
from collections import Counter
input = lambda: sys.stdin.readline().strip()
import math
inf = 10 ** 18
def I():
return input()
def II():
return int(input())
def MII():
return map(int, input().split())
def LI():
return input().split()
def LII():
return list(map(int, input().split()))
def LFI():
return list(map(float, input().split()))
fmax = lambda x, y: x if x > y else y
fmin = lambda x, y: x if x < y else y
isqrt = lambda x: int(math.sqrt(x))
'''
'''
def solve():
n = II()
a = LII()
if 0 in a:
print("NO")
return
cnt = Counter(a)
if len(cnt) != 2:
print("YES")
else:
k = list(cnt.keys())
if k[0] + k[1] != 0:
print("YES")
else:
print("NO")
t = 1
# t = II()
for _ in range(t):
solve()

京公网安备 11010502036488号