提出 #60777922


ソースコード 拡げる

from collections import defaultdict
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int, input().split()))
K = 25
cur = [0] * (K + 1)
for k in range(K):
    kk = 1 << k
    s = defaultdict(lambda: (0, 0))
    for i in a:
        c1, c2 = s[-i % kk]
        s[-i % kk] = c1 + 1, c2 + i
        c1, c2 = s[i % kk]
        cur[k] += c2 + i * c1
ans = 0
for i in range(K):
    assert cur[i] % (1 << i) == 0
    ans += (cur[i] - cur[i + 1]) >> i
print(ans)

提出情報

提出日時
問題 F - Double Sum 2
ユーザ sounansya
言語 Python (PyPy 3.10-v7.3.12)
得点 500
コード長 490 Byte
結果 AC
実行時間 643 ms
メモリ 308116 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 500 / 500
結果
AC × 3
AC × 24
セット名 テストケース
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 02_random_10.txt, 02_random_11.txt, 02_random_12.txt, 02_random_13.txt, 02_random_14.txt, 02_random_15.txt, 02_random_16.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 73 ms 77016 KiB
00_sample_01.txt AC 74 ms 76864 KiB
00_sample_02.txt AC 74 ms 76832 KiB
01_handmade_00.txt AC 237 ms 111796 KiB
01_handmade_01.txt AC 239 ms 116288 KiB
01_handmade_02.txt AC 242 ms 111740 KiB
01_handmade_03.txt AC 186 ms 96520 KiB
02_random_00.txt AC 628 ms 307488 KiB
02_random_01.txt AC 633 ms 307612 KiB
02_random_02.txt AC 627 ms 307604 KiB
02_random_03.txt AC 633 ms 307924 KiB
02_random_04.txt AC 643 ms 308116 KiB
02_random_05.txt AC 147 ms 91232 KiB
02_random_06.txt AC 610 ms 304964 KiB
02_random_07.txt AC 637 ms 303208 KiB
02_random_08.txt AC 642 ms 304464 KiB
02_random_09.txt AC 637 ms 304460 KiB
02_random_10.txt AC 636 ms 301548 KiB
02_random_11.txt AC 639 ms 304040 KiB
02_random_12.txt AC 627 ms 304796 KiB
02_random_13.txt AC 243 ms 111216 KiB
02_random_14.txt AC 265 ms 110448 KiB
02_random_15.txt AC 262 ms 111364 KiB
02_random_16.txt AC 258 ms 111136 KiB