結果
問題 | No.1505 Zero-Product Ranges |
ユーザー |
|
提出日時 | 2022-01-02 18:31:19 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 85 ms / 2,000 ms |
コード長 | 633 bytes |
コンパイル時間 | 1,883 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 98,176 KB |
最終ジャッジ日時 | 2024-10-11 22:20:28 |
合計ジャッジ時間 | 5,573 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 49 |
ソースコード
N = int(input())A = list(map(int, input().split()))A.append(0)all = N * (N + 1) // 2N += 1def search_one():a = 0b = len(A)while True:j = a + (b - a) // 2if '1' * j in A:a = jelse:b = jif b - a < 3:breakreturn bonecnt = 0now = 'zero'for i in range(N):if A[i] == 1:if now == 'zero':cnt = 1now = 'one'else:cnt += 1else:if now == 'one':onecnt += (cnt * (cnt + 1) // 2)#print(i, cnt)now = 'zero'print(all - onecnt)