結果
| 問題 |
No.1990 Candy Boxes
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 14:54:20 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 807 bytes |
| コンパイル時間 | 560 ms |
| コンパイル使用メモリ | 82,504 KB |
| 実行使用メモリ | 116,600 KB |
| 最終ジャッジ日時 | 2025-06-12 14:57:31 |
| 合計ジャッジ時間 | 7,891 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 53 WA * 18 |
ソースコード
def main():
import sys
input = sys.stdin.read().split()
N = int(input[0])
B = list(map(int, input[1:N+1]))
if N == 1:
print("Yes")
return
# Compute the alternating sum S
S = B[0]
for i in range(1, N-1):
if i % 2 == 1:
S -= B[i]
else:
S += B[i]
if S != B[-1]:
print("No")
return
# Compute x_i
x = []
x.append(B[0])
for i in range(1, N-1):
next_x = B[i] - x[i-1]
x.append(next_x)
# Check if x[-1] == B[-1]
if x[-1] != B[-1]:
print("No")
return
# Check all x are non-negative
for num in x:
if num < 0:
print("No")
return
print("Yes")
if __name__ == '__main__':
main()
gew1fw