結果
| 問題 |
No.3017 交互浴
|
| ユーザー |
detteiuu
|
| 提出日時 | 2025-01-25 13:54:20 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 655 bytes |
| コンパイル時間 | 375 ms |
| コンパイル使用メモリ | 82,316 KB |
| 実行使用メモリ | 107,816 KB |
| 最終ジャッジ日時 | 2025-01-25 23:02:15 |
| 合計ジャッジ時間 | 12,529 ms |
|
ジャッジサーバーID (参考情報) |
judge9 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 15 WA * 40 |
ソースコード
N = int(input())
H = list(map(int, input().split()))
stack = []
for i in range(N):
if i%2 == 0:
color = 0
else:
color = 1
while stack and stack[-1][0] <= H[i]:
stack.pop()
if len(stack) == 0:
if color == 0:
print(H[i])
else:
print(0)
stack.append((H[i], color, H[i]))
elif stack[-1][1] == color:
print(stack[-1][2])
else:
if color == 0:
print(stack[-1][2]+H[i])
stack.append((H[i], color, stack[-1][2]+H[i]))
else:
print(stack[-1][2]-H[i])
stack.append((H[i], color, stack[-1][2]-H[i]))
detteiuu