結果
問題 | No.3017 交互浴 |
ユーザー |
|
提出日時 | 2025-02-24 21:22:17 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 251 ms / 2,000 ms |
コード長 | 804 bytes |
コンパイル時間 | 452 ms |
コンパイル使用メモリ | 82,236 KB |
実行使用メモリ | 107,264 KB |
最終ジャッジ日時 | 2025-02-24 21:22:38 |
合計ジャッジ時間 | 20,122 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 55 |
ソースコード
N = int(input())H =list(map(int,input().split()))now = 0stack = []for i in range(N):h = H[i]if i % 2 == 0:if len(stack) == 0:now = hstack.append((0,h))print(now)else:while True:if stack:a,b = stack.pop()if b <= h:now -= b - acontinueelif a <= h <= b:now += astack.append((0,b))breakelse:now += hstack.append((a,b))stack.append((0,h))breakelse:now += hstack.append((0,h))breakprint(now)else:while True:if len(stack) == 0:breakelse:a,b = stack.pop()if b <= h:now -= b - acontinueelif a <= h < b:now -= h - astack.append((h,b))breakelse:stack.append((a,b))breakprint(now)