結果
| 問題 |
No.2300 Substring OR Sum
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 18:41:16 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 165 ms / 2,000 ms |
| コード長 | 559 bytes |
| コンパイル時間 | 331 ms |
| コンパイル使用メモリ | 82,468 KB |
| 実行使用メモリ | 108,340 KB |
| 最終ジャッジ日時 | 2025-03-20 18:41:37 |
| 合計ジャッジ時間 | 3,443 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
n = int(input())
a = list(map(int, input().split()))
total_subarrays = n * (n + 1) // 2
result = 0
for k in range(28): # Process each bit from 0 to 27
count_zero = 0
current = 0
for num in a:
if (num & (1 << k)) == 0:
current += 1
else:
count_zero += current * (current + 1) // 2
current = 0
# Add the last segment of zeros after loop ends
count_zero += current * (current + 1) // 2
contribution = (total_subarrays - count_zero) * (1 << k)
result += contribution
print(result)
lam6er