結果

問題 No.2300 Substring OR Sum
ユーザー lloyzlloyz
提出日時 2023-05-12 22:43:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 416 ms / 2,000 ms
コード長 476 bytes
コンパイル時間 609 ms
コンパイル使用メモリ 87,288 KB
実行使用メモリ 147,884 KB
最終ジャッジ日時 2023-08-19 05:36:00
合計ジャッジ時間 6,015 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
71,588 KB
testcase_01 AC 62 ms
71,280 KB
testcase_02 AC 66 ms
71,344 KB
testcase_03 AC 153 ms
94,716 KB
testcase_04 AC 136 ms
88,212 KB
testcase_05 AC 153 ms
95,288 KB
testcase_06 AC 114 ms
82,880 KB
testcase_07 AC 416 ms
142,336 KB
testcase_08 AC 193 ms
101,608 KB
testcase_09 AC 166 ms
95,900 KB
testcase_10 AC 344 ms
122,556 KB
testcase_11 AC 368 ms
139,000 KB
testcase_12 AC 400 ms
142,252 KB
testcase_13 AC 346 ms
147,884 KB
testcase_14 AC 303 ms
134,544 KB
testcase_15 AC 197 ms
103,072 KB
testcase_16 AC 312 ms
122,544 KB
testcase_17 AC 391 ms
142,228 KB
testcase_18 AC 60 ms
71,260 KB
testcase_19 AC 59 ms
71,312 KB
testcase_20 AC 61 ms
71,320 KB
testcase_21 AC 63 ms
71,384 KB
testcase_22 AC 61 ms
71,328 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