結果

問題 No.1505 Zero-Product Ranges
ユーザー wolgnikwolgnik
提出日時 2021-05-14 22:11:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 238 bytes
コンパイル時間 468 ms
コンパイル使用メモリ 82,168 KB
実行使用メモリ 100,480 KB
最終ジャッジ日時 2024-10-02 01:28:26
合計ジャッジ時間 5,133 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 49
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int, input().split()))
res = N * (N + 1) // 2
r = 0
for l in range(N):
  if a[l] == 0: continue
  if r < l: r = l
  while r < N and a[r]: r += 1
  res -= r - l
print(res)
0