結果
| 問題 |
No.1077 Noelちゃんと星々4
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-03-16 23:28:31 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 56 ms / 2,000 ms |
| コード長 | 253 bytes |
| コンパイル時間 | 272 ms |
| コンパイル使用メモリ | 81,904 KB |
| 実行使用メモリ | 64,640 KB |
| 最終ジャッジ日時 | 2024-09-25 02:26:47 |
| 合計ジャッジ時間 | 2,428 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 20 |
ソースコード
from heapq import heappush, heappop
n = int(input())
H = list(map(int,input().split()))
ans = 0
lis = []
for h in H:
if lis and lis[0] < -h:
l = -heappop(lis)
ans += abs(l-h)
heappush(lis,-h)
heappush(lis,-h)
print(ans)