結果
問題 | No.929 よくあるボールを移動するやつ |
ユーザー |
![]() |
提出日時 | 2025-03-20 18:47:25 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 65 ms / 2,000 ms |
コード長 | 614 bytes |
コンパイル時間 | 152 ms |
コンパイル使用メモリ | 82,444 KB |
実行使用メモリ | 81,724 KB |
最終ジャッジ日時 | 2025-03-20 18:48:12 |
合計ジャッジ時間 | 1,823 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 12 |
ソースコード
n = int(input())b = list(map(int, input().split()))ans = 0current_target = 0for i in range(n):cnt = b[i]if cnt == 0:continuestart = current_targetend = current_target + cnt - 1if i >= end:total = cnt * i - (start + end) * cnt // 2elif i <= start:total = (start + end) * cnt // 2 - cnt * ielse:m_left = i - start + 1sum_left = i * m_left - (start + i) * m_left // 2m_right = end - isum_right = m_right * (m_right + 1) // 2total = sum_left + sum_rightans += totalcurrent_target += cntprint(ans)