結果
| 問題 |
No.2300 Substring OR Sum
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-05-18 22:20:17 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 547 ms / 2,000 ms |
| コード長 | 457 bytes |
| コンパイル時間 | 380 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 178,500 KB |
| 最終ジャッジ日時 | 2024-12-16 10:44:28 |
| 合計ジャッジ時間 | 8,083 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
from collections import *
from itertools import *
from heapq import *
from functools import *
import sys,math
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
M = len(bin(max(A)))-2
ans = ((1<<M) - 1)*N*(N+1)//2
for bit in range(M):
X = []
for i in range(N):
X.append((A[i]>>bit)&1)
for g,r in groupby(X):
if g==0:
n = len(list(r))
ans -= (1<<bit)*n*(n+1)//2
print(ans)