結果

問題 No.2300 Substring OR Sum
ユーザー ShirotsumeShirotsume
提出日時 2023-02-28 23:14:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 421 ms / 2,000 ms
コード長 621 bytes
コンパイル時間 404 ms
コンパイル使用メモリ 86,996 KB
実行使用メモリ 263,484 KB
最終ジャッジ日時 2023-08-19 03:22:28
合計ジャッジ時間 7,100 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
73,532 KB
testcase_01 AC 97 ms
73,524 KB
testcase_02 AC 93 ms
73,156 KB
testcase_03 AC 207 ms
136,232 KB
testcase_04 AC 190 ms
126,628 KB
testcase_05 AC 229 ms
145,252 KB
testcase_06 AC 165 ms
102,516 KB
testcase_07 AC 421 ms
158,680 KB
testcase_08 AC 236 ms
159,584 KB
testcase_09 AC 219 ms
142,748 KB
testcase_10 AC 341 ms
158,156 KB
testcase_11 AC 389 ms
162,280 KB
testcase_12 AC 405 ms
164,472 KB
testcase_13 AC 338 ms
263,484 KB
testcase_14 AC 316 ms
260,308 KB
testcase_15 AC 250 ms
171,012 KB
testcase_16 AC 343 ms
148,488 KB
testcase_17 AC 401 ms
170,860 KB
testcase_18 AC 98 ms
73,452 KB
testcase_19 AC 93 ms
73,412 KB
testcase_20 AC 93 ms
73,292 KB
testcase_21 AC 92 ms
73,372 KB
testcase_22 AC 92 ms
73,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque, Counter
input = lambda: sys.stdin.readline().rstrip()
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(mi())
inf = 2 ** 63 - 1
mod = 998244353
import random
n = ii()
a = li()
ans = (-1 + (1 << 30)) * (n * (n + 1) // 2)
for bit in range(30):
    b = []
    for v in a:
        if 1 & (v >> bit):
            b.append(1)
        else:
            b.append(0)
    cnt = 0
    b.append(1)
    for v in b:
        if v != 0:
            ans -= (1 << bit) * cnt * (cnt + 1) // 2
            cnt = 0
        else:
            cnt += 1
print(ans)
    

0