結果

問題 No.2300 Substring OR Sum
ユーザー titiatitia
提出日時 2023-05-12 22:50:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 191 ms / 2,000 ms
コード長 350 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 87,160 KB
実行使用メモリ 104,168 KB
最終ジャッジ日時 2023-08-19 05:43:20
合計ジャッジ時間 4,531 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,516 KB
testcase_01 AC 63 ms
71,320 KB
testcase_02 AC 62 ms
71,340 KB
testcase_03 AC 102 ms
83,248 KB
testcase_04 AC 95 ms
82,044 KB
testcase_05 AC 99 ms
84,192 KB
testcase_06 AC 86 ms
79,296 KB
testcase_07 AC 177 ms
100,344 KB
testcase_08 AC 111 ms
87,144 KB
testcase_09 AC 103 ms
84,340 KB
testcase_10 AC 149 ms
100,224 KB
testcase_11 AC 170 ms
102,964 KB
testcase_12 AC 191 ms
99,884 KB
testcase_13 AC 126 ms
100,252 KB
testcase_14 AC 121 ms
104,168 KB
testcase_15 AC 115 ms
88,524 KB
testcase_16 AC 154 ms
100,420 KB
testcase_17 AC 179 ms
100,196 KB
testcase_18 AC 66 ms
71,156 KB
testcase_19 AC 67 ms
71,396 KB
testcase_20 AC 64 ms
71,472 KB
testcase_21 AC 63 ms
71,324 KB
testcase_22 AC 62 ms
71,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

N=int(input())
A=list(map(int,input().split()))

ALL=N*(N+1)//2

ANS=0

for i in range(30):
    score=0
    now=0

    for a in A:
        if a & (1<<i) == 0:
            now+=1
        else:
            score+=now*(now+1)//2
            now=0

    score+=now*(now+1)//2
    ANS+=(ALL-score)*(1<<i)

print(ANS)
0