結果

問題 No.2300 Substring OR Sum
ユーザー lloyzlloyz
提出日時 2023-05-12 22:43:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 502 ms / 2,000 ms
コード長 476 bytes
コンパイル時間 165 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 146,588 KB
最終ジャッジ日時 2024-05-06 12:46:39
合計ジャッジ時間 6,480 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
51,840 KB
testcase_01 AC 38 ms
52,224 KB
testcase_02 AC 38 ms
52,480 KB
testcase_03 AC 183 ms
87,492 KB
testcase_04 AC 149 ms
87,780 KB
testcase_05 AC 181 ms
93,972 KB
testcase_06 AC 111 ms
81,920 KB
testcase_07 AC 499 ms
132,116 KB
testcase_08 AC 235 ms
94,932 KB
testcase_09 AC 195 ms
95,352 KB
testcase_10 AC 398 ms
117,508 KB
testcase_11 AC 463 ms
129,092 KB
testcase_12 AC 502 ms
132,084 KB
testcase_13 AC 419 ms
146,588 KB
testcase_14 AC 368 ms
133,836 KB
testcase_15 AC 250 ms
101,800 KB
testcase_16 AC 394 ms
117,360 KB
testcase_17 AC 501 ms
131,960 KB
testcase_18 AC 44 ms
51,712 KB
testcase_19 AC 41 ms
52,096 KB
testcase_20 AC 42 ms
52,224 KB
testcase_21 AC 42 ms
51,840 KB
testcase_22 AC 42 ms
52,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline

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

Pow2 = [pow(2, i) for i in range(28)]
D = [[0 for _ in range(28)] for _ in range(n)]
for i in range(n):
    a = A[i]
    for j in range(28):
        a, r = divmod(a, 2)
        D[i][j] = r
ans = 0
for i in range(28):
    cnt = 0
    one_last_idx = -1
    for j in range(n):
        if D[j][i] == 1:
            one_last_idx = j
        ans += Pow2[i] * (one_last_idx + 1)
print(ans)
0