結果
問題 | No.1505 Zero-Product Ranges |
ユーザー |
![]() |
提出日時 | 2021-05-17 17:35:54 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 90 ms / 2,000 ms |
コード長 | 718 bytes |
コンパイル時間 | 468 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 99,840 KB |
最終ジャッジ日時 | 2024-10-06 19:47:20 |
合計ジャッジ時間 | 5,247 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 49 |
ソースコード
#!/usr/bin/env python3import sysimport mathfrom bisect import bisect_right as brfrom bisect import bisect_left as blsys.setrecursionlimit(2147483647)from heapq import heappush, heappop,heappushpopfrom collections import defaultdictfrom itertools import accumulate, chainfrom collections import Counterfrom collections import dequefrom operator import itemgetterfrom itertools import permutationsmod = 10**9 + 7inf = float('inf')def I(): return int(sys.stdin.readline())def LI(): return list(map(int,sys.stdin.readline().split()))n = I()a = LI()ans = 0cnt = 0for i in range(n):if a[i] == 0:cnt += 1ans += cnt * (n - i)cnt = 0else:cnt += 1print(ans)