結果
問題 | No.3017 交互浴 |
ユーザー |
|
提出日時 | 2025-02-02 02:11:41 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 309 ms / 2,000 ms |
コード長 | 374 bytes |
コンパイル時間 | 1,025 ms |
コンパイル使用メモリ | 81,920 KB |
実行使用メモリ | 107,588 KB |
最終ジャッジ日時 | 2025-02-02 02:12:06 |
合計ジャッジ時間 | 23,517 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 55 |
ソースコード
N=int(input())A=list(map(int,input().split()))ans=0stack=[]for i in range(N):while stack and stack[-1][0]<=A[i]:h,c,l=stack.pop()if c==0 : ans-=lif stack:if stack[-1][1]==0 : ans-=stack[-1][2]-stack[-1][0]+A[i]stack[-1][2]=stack[-1][0]-A[i]stack.append([A[i],i&1,A[i]]) #(h,c,l)if i&1==0 : ans+=A[i]print(ans)