結果

問題 No.2300 Substring OR Sum
ユーザー 👑 rin204rin204
提出日時 2024-03-16 16:06:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 330 bytes
コンパイル時間 861 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 107,368 KB
最終ジャッジ日時 2024-03-16 16:07:05
合計ジャッジ時間 4,656 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,332 KB
testcase_01 AC 38 ms
53,332 KB
testcase_02 AC 37 ms
53,332 KB
testcase_03 AC 75 ms
75,416 KB
testcase_04 AC 72 ms
74,236 KB
testcase_05 AC 77 ms
76,448 KB
testcase_06 AC 62 ms
69,048 KB
testcase_07 AC 162 ms
107,368 KB
testcase_08 AC 89 ms
81,532 KB
testcase_09 AC 80 ms
76,612 KB
testcase_10 AC 132 ms
97,888 KB
testcase_11 AC 147 ms
103,568 KB
testcase_12 AC 164 ms
107,288 KB
testcase_13 AC 106 ms
101,800 KB
testcase_14 AC 90 ms
98,104 KB
testcase_15 AC 95 ms
83,056 KB
testcase_16 AC 131 ms
98,168 KB
testcase_17 AC 160 ms
107,028 KB
testcase_18 AC 36 ms
53,332 KB
testcase_19 AC 36 ms
53,332 KB
testcase_20 AC 35 ms
53,332 KB
testcase_21 AC 36 ms
53,332 KB
testcase_22 AC 36 ms
53,332 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
A = list(map(int, input().split()))
ans = 0

for i in range(30):
    tot = 0
    row = 0
    for a in A:
        if a >> i & 1:
            tot += row * (row + 1) // 2
            row = 0
        else:
            row += 1
    tot += row * (row + 1) // 2
    ans += (n * (n + 1) // 2 - tot) * (1 << i)
print(ans)
0