結果
問題 | No.3017 交互浴 |
ユーザー |
|
提出日時 | 2025-01-25 12:43:33 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 208 ms / 2,000 ms |
コード長 | 374 bytes |
コンパイル時間 | 274 ms |
コンパイル使用メモリ | 82,280 KB |
実行使用メモリ | 104,704 KB |
最終ジャッジ日時 | 2025-01-25 22:19:03 |
合計ジャッジ時間 | 13,898 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 55 |
ソースコード
from collections import dequeN=int(input())H=list(map(int,input().split()))d=deque([(1<<60,0)])ans=0cnt=1for h in H:while d[0][0]<h:ans-=d[0][0]*d[0][1]if d[0][1]==0:ans+=d[0][0]d.popleft()if d[0][1]!=cnt:d.appendleft((h,cnt))ans+=h*cntif cnt==0:ans-=hcnt^=1print(ans)