結果
| 問題 | No.2300 Substring OR Sum |
| コンテスト | |
| ユーザー |
sepa38
|
| 提出日時 | 2023-05-12 21:48:37 |
| 言語 | PyPy3 (7.3.23 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 716 ms / 2,000 ms |
| + 457µs | |
| コード長 | 439 bytes |
| 記録 | |
| コンパイル時間 | 65 ms |
| コンパイル使用メモリ | 82,968 KB |
| 実行使用メモリ | 302,464 KB |
| 最終ジャッジ日時 | 2026-10-01 12:46:38 |
| 合計ジャッジ時間 | 8,734 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
import bisect
n = int(input())
a = list(map(int, input().split()))
k = 28
ls = [[] for _ in range(k)]
for i in range(n):
for j in range(k):
if a[i] & (1 << j):
ls[j].append(i)
ans = 0
for i in range(n):
for j in range(k):
if a[i] & (1 << j):
ans += (n - i) * (1 << j)
continue
else:
idx = bisect.bisect_right(ls[j], i)
if idx < len(ls[j]):
ans += (n - ls[j][idx]) * (1 << j)
print(ans)
sepa38