結果

問題 No.1505 Zero-Product Ranges
ユーザー lllllll88938494
提出日時 2022-01-12 00:25:09
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 326 bytes
コンパイル時間 342 ms
コンパイル使用メモリ 81,904 KB
実行使用メモリ 264,180 KB
最終ジャッジ日時 2024-11-14 12:19:05
合計ジャッジ時間 8,662 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 48 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
ns=list(map(int,input().split()))
s=''
box=[]
for i in range(n):
    if ns[i] == 1:
        s+='1'
        if i == n-1:
            box.append(s)
    else:
        if len(s) > 0:
            box.append(s)
        s=''
h=0
for i in box:
    h += (len(i)+1)*len(i) // 2
    
total = (n+1)*n // 2

print(total-h)

0