結果

問題 No.2300 Substring OR Sum
ユーザー ニックネームニックネーム
提出日時 2023-05-12 21:41:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 437 ms / 2,000 ms
コード長 357 bytes
コンパイル時間 749 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 260,236 KB
最終ジャッジ日時 2024-05-06 11:28:01
合計ジャッジ時間 5,109 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
51,968 KB
testcase_01 AC 41 ms
52,096 KB
testcase_02 AC 42 ms
52,224 KB
testcase_03 AC 139 ms
117,872 KB
testcase_04 AC 128 ms
109,840 KB
testcase_05 AC 145 ms
124,536 KB
testcase_06 AC 94 ms
81,024 KB
testcase_07 AC 346 ms
256,636 KB
testcase_08 AC 165 ms
146,884 KB
testcase_09 AC 137 ms
126,696 KB
testcase_10 AC 287 ms
241,376 KB
testcase_11 AC 312 ms
256,972 KB
testcase_12 AC 332 ms
256,640 KB
testcase_13 AC 437 ms
260,236 KB
testcase_14 AC 75 ms
97,408 KB
testcase_15 AC 179 ms
157,328 KB
testcase_16 AC 287 ms
242,640 KB
testcase_17 AC 331 ms
256,328 KB
testcase_18 AC 37 ms
51,968 KB
testcase_19 AC 38 ms
52,224 KB
testcase_20 AC 38 ms
52,096 KB
testcase_21 AC 37 ms
52,096 KB
testcase_22 AC 38 ms
51,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int,input().split()))
m = max(a).bit_length()
b = [[-1] for _ in range(m)]
for i,v in enumerate(a):
    for j in range(m):
        if v>>j&1: b[j].append(i)
for i in range(m): b[i].append(n)
ans = ((1<<m)-1)*(n+1)*n//2
for i in range(m):
    for l,r in zip(b[i][:-1],b[i][1:]):
        ans -= (1<<i)*(r-l)*(r-l-1)//2
print(ans)
0