結果

問題 No.2300 Substring OR Sum
ユーザー とろちゃとろちゃ
提出日時 2023-05-12 23:02:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 833 ms / 2,000 ms
コード長 1,021 bytes
コンパイル時間 215 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 226,708 KB
最終ジャッジ日時 2024-05-06 13:04:14
合計ジャッジ時間 8,749 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
53,760 KB
testcase_01 AC 43 ms
53,888 KB
testcase_02 AC 44 ms
54,272 KB
testcase_03 AC 274 ms
96,380 KB
testcase_04 AC 234 ms
93,048 KB
testcase_05 AC 289 ms
97,280 KB
testcase_06 AC 173 ms
86,656 KB
testcase_07 AC 761 ms
153,856 KB
testcase_08 AC 342 ms
104,792 KB
testcase_09 AC 296 ms
99,000 KB
testcase_10 AC 612 ms
129,236 KB
testcase_11 AC 699 ms
146,948 KB
testcase_12 AC 762 ms
154,760 KB
testcase_13 AC 833 ms
226,708 KB
testcase_14 AC 138 ms
104,376 KB
testcase_15 AC 364 ms
106,492 KB
testcase_16 AC 601 ms
129,332 KB
testcase_17 AC 737 ms
152,412 KB
testcase_18 AC 47 ms
53,760 KB
testcase_19 AC 47 ms
54,016 KB
testcase_20 AC 47 ms
53,504 KB
testcase_21 AC 47 ms
53,760 KB
testcase_22 AC 49 ms
54,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# import pypyjit;pypyjit.set_param("max_unroll_recursion=-1")
# from bisect import *
from collections import *

# from heapq import *
# from itertools import *
# from math import *
# from datetime import *
# from decimal import*
# from string import ascii_lowercase,ascii_uppercase
# import numpy as np
import sys
import os

# sys.setrecursionlimit(10**6)
INF = 10**18
MOD = 998244353
# MOD = 10**9 + 7
File = open("input.txt", "r") if os.path.exists("input.txt") else sys.stdin


def input():
    return File.readline()[:-1]


# ///////////////////////////////////////////////////////////////////////////


N = int(input())
A = list(map(int, input().split()))
total = [deque() for _ in range(28)]
for i in range(N):
    for j in range(28):
        if A[i] >> j & 1:
            total[j].append(N - i)

ans = 0
for i in range(N):
    for j in range(28):
        if len(total[j]) == 0:
            continue
        ans += 2**j * min(N - i, total[j][0])
        if A[i] >> j & 1:
            total[j].popleft()

print(ans)
0