結果

問題 No.1505 Zero-Product Ranges
ユーザー mesame3993
提出日時 2021-09-30 01:15:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 206 bytes
コンパイル時間 324 ms
コンパイル使用メモリ 82,316 KB
実行使用メモリ 97,280 KB
最終ジャッジ日時 2024-07-17 03:49:33
合計ジャッジ時間 5,045 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #

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