結果
| 問題 | No.904 サメトロ |
| コンテスト | |
| ユーザー |
H20
|
| 提出日時 | 2021-08-03 10:29:34 |
| 言語 | PyPy3 (8.0.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 635 bytes |
| 記録 | |
| コンパイル時間 | 255 ms |
| コンパイル使用メモリ | 96,104 KB |
| 実行使用メモリ | 83,584 KB |
| 最終ジャッジ日時 | 2026-08-28 20:04:31 |
| 合計ジャッジ時間 | 4,876 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 24 WA * 9 |
ソースコード
import copy
N = int(input())
A = []
B = []
for i in range(N-1):
a,b = map(int,input().split())
A.append(a)
B.append(b)
ma = max(sum(A),sum(B))
amarib = 0
D = copy.deepcopy(A)
for i in range(len(A)):
b = B[i]
for j in reversed(range(len(A))):
if i==j:
continue
temp = min(D[j],b)
b-=temp
D[j]-=temp
amarib += b
amaria = 0
D = copy.deepcopy(B)
for i in range(len(A)):
a = A[i]
for j in reversed(range(len(A))):
if i==j:
continue
temp = min(D[j],a)
a-=temp
D[j]-=temp
amaria += a
print(ma-max(amaria,amarib)+1)
H20