結果
問題 | No.1505 Zero-Product Ranges |
ユーザー |
|
提出日時 | 2022-01-05 21:24:06 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 145 ms / 2,000 ms |
コード長 | 305 bytes |
コンパイル時間 | 155 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 14,848 KB |
最終ジャッジ日時 | 2024-11-06 08:39:53 |
合計ジャッジ時間 | 7,202 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 49 |
ソースコード
n = int(input()) A = list(map(int, input().split())) ans = n * (n - 1) // 2 + n cnt = 0 for i in range(n): if A[i] == 1: cnt += 1 if i == n - 1: ans -= cnt * (cnt - 1) // 2 + cnt else: ans -= cnt * (cnt - 1) // 2 + cnt cnt = 0 print(ans)