結果
問題 | No.1505 Zero-Product Ranges |
ユーザー |
|
提出日時 | 2021-05-18 15:38:31 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 85 ms / 2,000 ms |
コード長 | 299 bytes |
コンパイル時間 | 1,459 ms |
コンパイル使用メモリ | 82,520 KB |
実行使用メモリ | 100,096 KB |
最終ジャッジ日時 | 2024-10-08 16:07:00 |
合計ジャッジ時間 | 7,540 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 49 |
ソースコード
n = int(input())a = list(map(int, input().split()))a.append(0)s = a[0]k = 0nc = 0for i in range(n + 1):if s == 0 and a[i] == 0:nc += (i - k)*(i - k + 1)/2s = 1continueif s == 1 and a[i] == 1:k = is = 0print(int(n * (n + 1) / 2 - nc))