結果
| 問題 |
No.1990 Candy Boxes
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 20:00:54 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 918 bytes |
| コンパイル時間 | 247 ms |
| コンパイル使用メモリ | 82,216 KB |
| 実行使用メモリ | 105,212 KB |
| 最終ジャッジ日時 | 2025-06-12 20:04:41 |
| 合計ジャッジ時間 | 7,416 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 53 WA * 18 |
ソースコード
def main():
import sys
input = sys.stdin.read().split()
idx = 0
N = int(input[idx])
idx += 1
B = list(map(int, input[idx:idx+N]))
idx += N
if N == 1:
# This case is not possible as per problem constraints (N >=2)
print("Yes")
return
# Compute the 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's and check non-negative
x = [0] * (N-1)
x[0] = B[0]
if x[0] < 0:
print("No")
return
for i in range(1, N-1):
x[i] = B[i] - x[i-1]
if x[i] < 0:
print("No")
return
# Check if the last x equals B[-1]
if x[-1] != B[-1]:
print("No")
return
print("Yes")
if __name__ == "__main__":
main()
gew1fw