結果
問題 | No.2918 Divide Applicants Fairly |
ユーザー | みうね |
提出日時 | 2024-09-20 19:00:53 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 753 bytes |
コンパイル時間 | 280 ms |
コンパイル使用メモリ | 82,212 KB |
実行使用メモリ | 240,064 KB |
最終ジャッジ日時 | 2024-10-07 11:32:23 |
合計ジャッジ時間 | 5,429 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
54,076 KB |
testcase_01 | AC | 40 ms
53,788 KB |
testcase_02 | AC | 41 ms
55,432 KB |
testcase_03 | AC | 41 ms
53,916 KB |
testcase_04 | AC | 40 ms
55,656 KB |
testcase_05 | AC | 41 ms
56,060 KB |
testcase_06 | AC | 43 ms
54,328 KB |
testcase_07 | AC | 41 ms
54,896 KB |
testcase_08 | AC | 39 ms
54,328 KB |
testcase_09 | AC | 59 ms
72,676 KB |
testcase_10 | AC | 39 ms
54,264 KB |
testcase_11 | AC | 707 ms
114,344 KB |
testcase_12 | AC | 57 ms
69,376 KB |
testcase_13 | AC | 47 ms
63,616 KB |
testcase_14 | AC | 41 ms
54,144 KB |
testcase_15 | TLE | - |
testcase_16 | AC | 39 ms
53,960 KB |
testcase_17 | AC | 57 ms
71,284 KB |
testcase_18 | AC | 710 ms
114,376 KB |
testcase_19 | AC | 38 ms
55,548 KB |
testcase_20 | AC | 365 ms
98,696 KB |
testcase_21 | AC | 59 ms
70,284 KB |
testcase_22 | AC | 42 ms
54,636 KB |
testcase_23 | AC | 63 ms
74,240 KB |
testcase_24 | AC | 46 ms
54,888 KB |
testcase_25 | AC | 1,413 ms
159,092 KB |
testcase_26 | AC | 40 ms
54,416 KB |
testcase_27 | AC | 218 ms
87,324 KB |
testcase_28 | AC | 39 ms
55,156 KB |
testcase_29 | AC | 50 ms
64,876 KB |
testcase_30 | AC | 39 ms
54,692 KB |
testcase_31 | AC | 56 ms
66,888 KB |
testcase_32 | AC | 40 ms
55,136 KB |
testcase_33 | AC | 39 ms
54,400 KB |
testcase_34 | AC | 39 ms
54,244 KB |
testcase_35 | AC | 38 ms
54,800 KB |
testcase_36 | AC | 184 ms
89,124 KB |
testcase_37 | AC | 128 ms
81,740 KB |
testcase_38 | AC | 93 ms
79,244 KB |
testcase_39 | AC | 799 ms
157,772 KB |
testcase_40 | AC | 77 ms
78,196 KB |
testcase_41 | AC | 88 ms
79,184 KB |
testcase_42 | AC | 108 ms
82,180 KB |
testcase_43 | AC | 150 ms
87,020 KB |
testcase_44 | AC | 236 ms
97,396 KB |
testcase_45 | AC | 384 ms
117,208 KB |
testcase_46 | AC | 39 ms
54,408 KB |
testcase_47 | AC | 40 ms
54,544 KB |
testcase_48 | AC | 58 ms
72,668 KB |
testcase_49 | AC | 131 ms
81,924 KB |
testcase_50 | AC | 41 ms
54,136 KB |
testcase_51 | AC | 59 ms
73,236 KB |
testcase_52 | AC | 104 ms
79,056 KB |
testcase_53 | AC | 71 ms
77,188 KB |
testcase_54 | AC | 68 ms
77,188 KB |
testcase_55 | AC | 80 ms
77,920 KB |
testcase_56 | AC | 77 ms
78,208 KB |
testcase_57 | AC | 229 ms
87,408 KB |
testcase_58 | AC | 76 ms
77,752 KB |
testcase_59 | AC | 77 ms
77,756 KB |
testcase_60 | AC | 50 ms
64,584 KB |
testcase_61 | AC | 79 ms
78,068 KB |
ソースコード
import math import collections N = int(input()) if N > 26: print(0) exit() rates = list(map(int, input().split())) rate_sums = list(range(math.factorial(N) // math.factorial(N // 2) // math.factorial(N - N // 2))) index = 0 stack = collections.deque() stack.append((0, 0, 0, -1)) while stack: bit, rate_sum, popcnt, k = stack.pop() if popcnt == N // 2: rate_sums[index] = 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): if ans > abs(rate_sums[i] - rate_sums[i + 1]): ans = abs(rate_sums[i] - rate_sums[i + 1]) print(ans)