結果
問題 | No.332 数列をプレゼントに |
ユーザー | maspy |
提出日時 | 2020-04-15 01:16:03 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,267 bytes |
コンパイル時間 | 360 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 318,548 KB |
最終ジャッジ日時 | 2024-10-01 18:31:38 |
合計ジャッジ時間 | 28,643 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 510 ms
44,172 KB |
testcase_01 | AC | 516 ms
44,428 KB |
testcase_02 | AC | 510 ms
44,296 KB |
testcase_03 | AC | 508 ms
44,560 KB |
testcase_04 | AC | 510 ms
44,556 KB |
testcase_05 | AC | 535 ms
60,436 KB |
testcase_06 | AC | 540 ms
71,052 KB |
testcase_07 | AC | 558 ms
86,028 KB |
testcase_08 | AC | 545 ms
73,096 KB |
testcase_09 | AC | 524 ms
44,296 KB |
testcase_10 | AC | 520 ms
44,684 KB |
testcase_11 | AC | 523 ms
48,524 KB |
testcase_12 | AC | 547 ms
55,952 KB |
testcase_13 | AC | 543 ms
61,964 KB |
testcase_14 | AC | 551 ms
62,860 KB |
testcase_15 | AC | 517 ms
44,808 KB |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | AC | 599 ms
133,136 KB |
testcase_19 | RE | - |
testcase_20 | AC | 524 ms
44,688 KB |
testcase_21 | AC | 525 ms
44,432 KB |
testcase_22 | AC | 520 ms
44,560 KB |
testcase_23 | AC | 545 ms
74,384 KB |
testcase_24 | AC | 541 ms
69,396 KB |
testcase_25 | AC | 541 ms
70,284 KB |
testcase_26 | AC | 538 ms
62,728 KB |
testcase_27 | AC | 523 ms
47,756 KB |
testcase_28 | AC | 527 ms
55,056 KB |
testcase_29 | AC | 534 ms
57,736 KB |
testcase_30 | AC | 531 ms
55,824 KB |
testcase_31 | AC | 523 ms
47,244 KB |
testcase_32 | AC | 525 ms
54,416 KB |
testcase_33 | AC | 515 ms
44,304 KB |
testcase_34 | AC | 528 ms
49,036 KB |
testcase_35 | MLE | - |
testcase_36 | AC | 518 ms
44,680 KB |
testcase_37 | AC | 506 ms
44,688 KB |
testcase_38 | AC | 508 ms
44,680 KB |
testcase_39 | AC | 506 ms
44,556 KB |
testcase_40 | AC | 519 ms
44,552 KB |
testcase_41 | AC | 519 ms
44,676 KB |
testcase_42 | AC | 509 ms
44,680 KB |
testcase_43 | AC | 509 ms
44,684 KB |
testcase_44 | AC | 511 ms
44,684 KB |
testcase_45 | AC | 545 ms
72,848 KB |
testcase_46 | AC | 507 ms
44,432 KB |
ソースコード
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N, X = map(int, readline().split()) A = list(map(int, read().split())) K = 10 ** 5 low = [] high = [] for x in A: if x <= K: low.append(x) else: high.append(x) L = len(low) H = len(high) dpl = [None] * (L + 1) dpl[0] = np.zeros(1, np.int64) for i, x in enumerate(low, 1): dp = np.full(len(dpl[i - 1]) + x, -1, np.int32) dp[:-x] = dpl[i - 1] dp[x:][dpl[i - 1] >= 0] = i dpl[i] = dp dph = np.zeros(1 << H, np.int64) for i, x in enumerate(high): dph[1 << i: 1 << i + 1] = dph[: 1 << i] + x nums = X - dph nums = nums[(0 <= nums) & (nums < len(dpl[-1]))] nums = nums[dpl[-1][nums] >= 0] if not len(nums): print('No') exit() low_sum = nums[0] high_sum = X - low_sum # 復元 low_ind = [] high_ind = [] n = len(low) while low_sum: n = dpl[n][low_sum] - 1 low_sum -= low[n] low_ind.append(n) i = np.where(dph == high_sum)[0] for j in range(H): if i & (1 << j): high_ind.append(j) nums = [low[i] for i in low_ind] + [high[i] for i in high_ind] for x in nums: i = A.index(x) A[i] = 0 answer = ''.join('x' if x else 'o' for x in A) print(answer)