結果

問題 No.1505 Zero-Product Ranges
ユーザー Kude
提出日時 2021-05-14 22:07:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 206 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 82,316 KB
実行使用メモリ 100,736 KB
最終ジャッジ日時 2024-10-02 01:21:37
合計ジャッジ時間 4,944 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
ans = (n + 1) * n // 2
a = list(map(int, input().split())) + [0]
now = 0
for x in a:
    if x == 0:
        ans -= (now + 1) * now // 2
        now = 0
    else:
        now += 1
print(ans)
0