結果
問題 | No.2918 Divide Applicants Fairly |
ユーザー | 高橋ゆに |
提出日時 | 2024-09-23 20:46:06 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 1,558 ms / 2,000 ms |
コード長 | 636 bytes |
コンパイル時間 | 329 ms |
コンパイル使用メモリ | 82,484 KB |
実行使用メモリ | 256,632 KB |
最終ジャッジ日時 | 2024-10-07 21:06:42 |
合計ジャッジ時間 | 10,135 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 36 ms
55,268 KB |
testcase_01 | AC | 38 ms
54,644 KB |
testcase_02 | AC | 37 ms
53,632 KB |
testcase_03 | AC | 37 ms
54,084 KB |
testcase_04 | AC | 37 ms
53,924 KB |
testcase_05 | AC | 38 ms
53,944 KB |
testcase_06 | AC | 39 ms
54,644 KB |
testcase_07 | AC | 37 ms
55,000 KB |
testcase_08 | AC | 37 ms
55,500 KB |
testcase_09 | AC | 57 ms
73,936 KB |
testcase_10 | AC | 39 ms
54,176 KB |
testcase_11 | AC | 893 ms
255,680 KB |
testcase_12 | AC | 56 ms
70,940 KB |
testcase_13 | AC | 48 ms
63,808 KB |
testcase_14 | AC | 40 ms
55,244 KB |
testcase_15 | AC | 39 ms
53,536 KB |
testcase_16 | AC | 38 ms
53,952 KB |
testcase_17 | AC | 62 ms
70,788 KB |
testcase_18 | AC | 837 ms
256,632 KB |
testcase_19 | AC | 40 ms
54,080 KB |
testcase_20 | AC | 411 ms
155,856 KB |
testcase_21 | AC | 56 ms
71,160 KB |
testcase_22 | AC | 40 ms
54,072 KB |
testcase_23 | AC | 60 ms
73,904 KB |
testcase_24 | AC | 38 ms
53,988 KB |
testcase_25 | AC | 1,558 ms
255,860 KB |
testcase_26 | AC | 39 ms
53,652 KB |
testcase_27 | AC | 248 ms
108,108 KB |
testcase_28 | AC | 41 ms
54,148 KB |
testcase_29 | AC | 51 ms
64,620 KB |
testcase_30 | AC | 38 ms
53,568 KB |
testcase_31 | AC | 50 ms
65,284 KB |
testcase_32 | AC | 38 ms
55,484 KB |
testcase_33 | AC | 38 ms
54,560 KB |
testcase_34 | AC | 36 ms
54,524 KB |
testcase_35 | AC | 37 ms
54,440 KB |
testcase_36 | AC | 213 ms
108,996 KB |
testcase_37 | AC | 138 ms
88,984 KB |
testcase_38 | AC | 100 ms
83,108 KB |
testcase_39 | AC | 40 ms
54,332 KB |
testcase_40 | AC | 77 ms
83,128 KB |
testcase_41 | AC | 100 ms
89,432 KB |
testcase_42 | AC | 133 ms
108,444 KB |
testcase_43 | AC | 189 ms
145,604 KB |
testcase_44 | AC | 319 ms
247,272 KB |
testcase_45 | AC | 586 ms
255,972 KB |
testcase_46 | AC | 40 ms
53,368 KB |
testcase_47 | AC | 38 ms
54,580 KB |
testcase_48 | AC | 57 ms
72,980 KB |
testcase_49 | AC | 140 ms
89,568 KB |
testcase_50 | AC | 37 ms
54,776 KB |
testcase_51 | AC | 57 ms
72,736 KB |
testcase_52 | AC | 105 ms
82,968 KB |
testcase_53 | AC | 68 ms
77,676 KB |
testcase_54 | AC | 68 ms
77,340 KB |
testcase_55 | AC | 80 ms
81,836 KB |
testcase_56 | AC | 80 ms
81,488 KB |
testcase_57 | AC | 249 ms
107,904 KB |
testcase_58 | AC | 80 ms
81,968 KB |
testcase_59 | AC | 81 ms
81,672 KB |
testcase_60 | AC | 48 ms
63,952 KB |
testcase_61 | AC | 79 ms
81,796 KB |
testcase_62 | AC | 55 ms
69,916 KB |
testcase_63 | AC | 57 ms
69,864 KB |
ソースコード
from collections import deque N = int(input()) if N > 25: print(0) exit() rates = list(map(int, input().split())) rate_sums = [] index = 0 stack = deque() stack.append((0, 0, 0, -1)) while stack: bit, rate_sum, popcnt, k = stack.pop() if popcnt == N // 2: rate_sums.append(rate_sum) index += 1 else: for i in range(k + 1, N - N // 2 + popcnt + 1): stack.append((bit | (1 << i), rate_sum + rates[i], popcnt + 1, i)) rate_sums.sort() ans = 1 << 30 for i in range(len(rate_sums) - 1): tmp = abs(rate_sums[i] - rate_sums[i + 1]) if ans > tmp: ans = tmp print(ans)