結果

問題 No.2300 Substring OR Sum
ユーザー miya145592miya145592
提出日時 2023-05-13 01:48:53
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 165 ms / 2,000 ms
コード長 317 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 107,888 KB
最終ジャッジ日時 2024-05-06 14:45:14
合計ジャッジ時間 4,337 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,096 KB
testcase_01 AC 36 ms
51,712 KB
testcase_02 AC 35 ms
52,096 KB
testcase_03 AC 77 ms
74,112 KB
testcase_04 AC 73 ms
72,448 KB
testcase_05 AC 77 ms
75,392 KB
testcase_06 AC 62 ms
68,480 KB
testcase_07 AC 158 ms
107,888 KB
testcase_08 AC 87 ms
80,000 KB
testcase_09 AC 80 ms
76,544 KB
testcase_10 AC 138 ms
98,436 KB
testcase_11 AC 154 ms
104,064 KB
testcase_12 AC 163 ms
107,520 KB
testcase_13 AC 121 ms
101,852 KB
testcase_14 AC 97 ms
97,536 KB
testcase_15 AC 97 ms
82,560 KB
testcase_16 AC 133 ms
98,560 KB
testcase_17 AC 165 ms
107,264 KB
testcase_18 AC 38 ms
51,968 KB
testcase_19 AC 39 ms
52,224 KB
testcase_20 AC 39 ms
51,940 KB
testcase_21 AC 40 ms
52,224 KB
testcase_22 AC 38 ms
51,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
ans = 0
all = N*(N+1)//2
for j in range(28):
    cnt = 0
    ng = 0
    for i in range(N):
        if (A[i]>>j)&1==0:
            cnt+=1
        else:
            ng += cnt*(cnt+1)//2
            cnt=0
    ng += cnt*(cnt+1)//2
    ans += (1<<j)*(all-ng)
print(ans)
0