結果
問題 | No.929 よくあるボールを移動するやつ |
ユーザー |
![]() |
提出日時 | 2019-12-18 20:58:13 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 58 ms / 2,000 ms |
コード長 | 305 bytes |
コンパイル時間 | 153 ms |
コンパイル使用メモリ | 82,008 KB |
実行使用メモリ | 80,920 KB |
最終ジャッジ日時 | 2024-07-06 23:01:16 |
合計ジャッジ時間 | 1,951 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 12 |
ソースコード
N = int(input())B = list(map(int, input().split()))lack = 0ans = 0for Bi in B:ans += abs(lack)if lack>=0 and Bi==0:lack += 1elif lack>=0 and Bi>0:lack -= Bi-1elif lack<0 and Bi==0:lack += 1elif lack<0 and Bi>0:lack -= Bi-1print(ans)