公式
B - N - 1 解説 by en_translator
Let \(A_k\) be the element being removed. Then the remaining \((N-1)\) elements sum to \(\displaystyle \sum_{i=1}^N A_i-A_k\). We want to determine if this value evaluates to \(M\) for some \(k\). This condition is equivalent to \(\displaystyle A_k=\sum_{i=1}^N A_i-M\), so it is sufficient to check the existence of such \(k\).
n, m = map(int, input().split())
a = list(map(int, input().split()))
if sum(a) - m in a:
print("Yes")
else:
print("No")
投稿日時:
最終更新: