結果
問題 | No.937 Ultra Sword |
ユーザー | maspy |
提出日時 | 2020-03-28 16:50:54 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 868 bytes |
コンパイル時間 | 282 ms |
コンパイル使用メモリ | 10,852 KB |
実行使用メモリ | 22,144 KB |
最終ジャッジ日時 | 2023-08-30 17:59:08 |
合計ジャッジ時間 | 20,417 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 275 ms
15,680 KB |
testcase_01 | WA | - |
testcase_02 | AC | 269 ms
15,844 KB |
testcase_03 | AC | 270 ms
15,588 KB |
testcase_04 | AC | 267 ms
16,012 KB |
testcase_05 | AC | 309 ms
20,296 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 273 ms
14,596 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 342 ms
19,176 KB |
testcase_27 | AC | 331 ms
19,440 KB |
testcase_28 | AC | 362 ms
19,628 KB |
testcase_29 | WA | - |
testcase_30 | AC | 336 ms
17,988 KB |
testcase_31 | AC | 359 ms
20,080 KB |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 280 ms
16,876 KB |
testcase_35 | AC | 264 ms
16,304 KB |
testcase_36 | AC | 340 ms
19,556 KB |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | AC | 262 ms
16,168 KB |
testcase_40 | AC | 338 ms
19,632 KB |
testcase_41 | AC | 283 ms
16,988 KB |
testcase_42 | AC | 314 ms
18,032 KB |
testcase_43 | WA | - |
testcase_44 | AC | 290 ms
16,956 KB |
testcase_45 | WA | - |
testcase_46 | AC | 311 ms
17,636 KB |
ソースコード
#!/usr/bin/ python3.8 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from functools import reduce U = 10 ** 5 N, *A = map(int, read().split()) num_count = [0] * (U + 1) for x in A: num_count[x] += 1 save_cost = [0] * (U + 1) for d in range(2, U + 1): save_cost[d] = sum((n - n // d) * num_count[n] for n in range(d, U + 1, d)) def gcd(a, b): if a < b: a, b = b, a while b: LA = a.bit_length() LB = b.bit_length() a ^= b << (LA - LB) if a < b: a, b = b, a return a g = reduce(gcd, A) cand = [g] for _ in range(17): cand += [(x << 1) ^ g for x in cand] max_save = 0 for d in cand: if 1 <= d <= U: x = save_cost[d] if max_save < x: max_save = x answer = sum(A) - max_save print(answer)