結果
問題 |
No.1505 Zero-Product Ranges
|
ユーザー |
![]() |
提出日時 | 2021-09-30 01:00:50 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 323 bytes |
コンパイル時間 | 293 ms |
コンパイル使用メモリ | 82,228 KB |
実行使用メモリ | 116,968 KB |
最終ジャッジ日時 | 2024-07-17 03:36:15 |
合計ジャッジ時間 | 5,110 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 WA * 22 |
ソースコード
n = int(input()) a = list(map(int, input().split())) li0 = [x for x in range(n) if a[x] == 0] li0 = list(reversed(li0)) ans = 0 if 0 not in a: print(0) exit() for i in range(n-1): if a[i] == 0: ans += n - i if i >= li0[-1]: li0.pop() else: if len(li0) == 0: break ans += n - i - (li0[-1]-i) print(ans)