結果
問題 | No.3017 交互浴 |
ユーザー |
|
提出日時 | 2025-01-25 15:55:11 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 638 bytes |
コンパイル時間 | 555 ms |
コンパイル使用メモリ | 82,276 KB |
実行使用メモリ | 107,816 KB |
最終ジャッジ日時 | 2025-01-25 23:49:27 |
合計ジャッジ時間 | 13,068 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 WA * 46 |
ソースコード
n=int(input())h=list(map(int,input().split()))stack=[]green=0blue=0for i in range(n):while len(stack)>0 and stack[-1][-1]<h[i]:a,b=stack.pop()if a==1:blue-=belse:green-=bif len(stack)>0:if stack[-1][-1]>h[i] and stack[-1][0] ==(i+1)%2:passelse:stack.append(((i+1)%2,h[i]))if (i+1)%2==1:blue+=h[i]else:green+=h[i]else:stack.append(((i+1)%2,h[i]))if (i+1)%2==1:blue+=h[i]else:green+=h[i]print(blue-green)