結果

問題 No.2918 Divide Applicants Fairly
ユーザー 高橋ゆに高橋ゆに
提出日時 2024-09-16 19:24:05
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 586 bytes
コンパイル時間 244 ms
コンパイル使用メモリ 82,044 KB
実行使用メモリ 130,516 KB
最終ジャッジ日時 2024-10-07 11:30:22
合計ジャッジ時間 8,943 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
52,000 KB
testcase_01 AC 38 ms
53,820 KB
testcase_02 AC 37 ms
53,144 KB
testcase_03 AC 38 ms
53,684 KB
testcase_04 AC 37 ms
52,736 KB
testcase_05 AC 46 ms
60,432 KB
testcase_06 AC 46 ms
60,820 KB
testcase_07 AC 38 ms
52,216 KB
testcase_08 AC 38 ms
52,948 KB
testcase_09 AC 177 ms
79,292 KB
testcase_10 AC 37 ms
53,136 KB
testcase_11 AC 37 ms
52,188 KB
testcase_12 AC 112 ms
76,972 KB
testcase_13 AC 51 ms
63,156 KB
testcase_14 AC 45 ms
61,760 KB
testcase_15 AC 37 ms
52,332 KB
testcase_16 AC 37 ms
52,756 KB
testcase_17 AC 114 ms
77,368 KB
testcase_18 AC 38 ms
53,784 KB
testcase_19 AC 37 ms
52,808 KB
testcase_20 AC 37 ms
52,280 KB
testcase_21 AC 115 ms
77,496 KB
testcase_22 AC 38 ms
53,260 KB
testcase_23 AC 180 ms
79,740 KB
testcase_24 AC 38 ms
53,804 KB
testcase_25 AC 37 ms
52,300 KB
testcase_26 AC 44 ms
61,408 KB
testcase_27 AC 37 ms
52,704 KB
testcase_28 AC 45 ms
62,492 KB
testcase_29 AC 51 ms
63,048 KB
testcase_30 AC 38 ms
52,376 KB
testcase_31 AC 54 ms
63,468 KB
testcase_32 AC 38 ms
53,856 KB
testcase_33 AC 38 ms
52,188 KB
testcase_34 AC 37 ms
52,416 KB
testcase_35 AC 38 ms
52,004 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 613 ms
128,456 KB
testcase_39 AC 38 ms
52,208 KB
testcase_40 AC 550 ms
129,360 KB
testcase_41 AC 38 ms
53,336 KB
testcase_42 AC 38 ms
53,012 KB
testcase_43 AC 38 ms
52,900 KB
testcase_44 AC 38 ms
52,432 KB
testcase_45 AC 38 ms
52,492 KB
testcase_46 AC 38 ms
52,760 KB
testcase_47 AC 38 ms
53,076 KB
testcase_48 AC 157 ms
79,640 KB
testcase_49 WA -
testcase_50 AC 43 ms
60,300 KB
testcase_51 AC 99 ms
79,404 KB
testcase_52 AC 1,574 ms
130,516 KB
testcase_53 AC 136 ms
91,120 KB
testcase_54 AC 176 ms
90,736 KB
testcase_55 AC 306 ms
106,612 KB
testcase_56 AC 215 ms
106,976 KB
testcase_57 AC 37 ms
53,072 KB
testcase_58 AC 216 ms
106,600 KB
testcase_59 AC 528 ms
106,980 KB
testcase_60 AC 50 ms
63,472 KB
testcase_61 AC 239 ms
106,756 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

if N > 20:
    print(0)
    exit()

rates = list(map(int, input().split()))
combs = [[] for k in range(20 + 1)]
rate_sums = [0 for comb in range(1 << N)]
for comb in range(1 << N):
    rate_sum = 0
    for i in range(N):
        if (comb >> i) & 1: rate_sum += rates[i]
    combs[comb.bit_count()].append(comb)
    rate_sums[comb] = rate_sum

ans = 2 ** 60
for k in range(1, 20 + 1):
    combs[k].sort(key = lambda comb: rate_sums[comb])
    for i in range(len(combs[k]) - 1):
        ans = min(ans, abs(rate_sums[combs[k][i]] - rate_sums[combs[k][i + 1]]))
print(ans)
0