結果

問題 No.1505 Zero-Product Ranges
ユーザー roaris
提出日時 2021-10-26 19:04:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 251 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 82,180 KB
実行使用メモリ 98,872 KB
最終ジャッジ日時 2024-10-05 19:52:04
合計ジャッジ時間 4,607 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
ans = N*(N+1)//2
now = 0

for Ai in A:
    if Ai==1:
        now += 1
    else:
        ans -= now*(now+1)//2
        now = 0

ans -= now*(now+1)//2
print(ans)
0