結果

問題 No.2918 Divide Applicants Fairly
ユーザー 高橋ゆに高橋ゆに
提出日時 2024-09-15 20:11:45
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 588 bytes
コンパイル時間 334 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 130,528 KB
最終ジャッジ日時 2024-10-07 11:30:23
合計ジャッジ時間 9,832 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
51,840 KB
testcase_01 AC 39 ms
52,096 KB
testcase_02 AC 39 ms
51,840 KB
testcase_03 AC 38 ms
52,224 KB
testcase_04 AC 39 ms
52,352 KB
testcase_05 AC 47 ms
60,288 KB
testcase_06 AC 46 ms
60,928 KB
testcase_07 AC 39 ms
51,968 KB
testcase_08 AC 39 ms
52,352 KB
testcase_09 AC 185 ms
79,744 KB
testcase_10 AC 38 ms
51,712 KB
testcase_11 AC 38 ms
51,712 KB
testcase_12 AC 117 ms
77,056 KB
testcase_13 AC 52 ms
62,336 KB
testcase_14 AC 47 ms
60,288 KB
testcase_15 AC 38 ms
51,584 KB
testcase_16 AC 38 ms
51,968 KB
testcase_17 AC 116 ms
77,056 KB
testcase_18 AC 38 ms
51,840 KB
testcase_19 AC 39 ms
52,224 KB
testcase_20 AC 39 ms
52,224 KB
testcase_21 AC 118 ms
77,424 KB
testcase_22 AC 39 ms
51,968 KB
testcase_23 AC 186 ms
79,584 KB
testcase_24 AC 39 ms
52,224 KB
testcase_25 AC 39 ms
51,712 KB
testcase_26 AC 47 ms
60,160 KB
testcase_27 AC 40 ms
51,968 KB
testcase_28 AC 47 ms
60,416 KB
testcase_29 AC 52 ms
62,464 KB
testcase_30 AC 40 ms
51,996 KB
testcase_31 AC 55 ms
63,232 KB
testcase_32 AC 40 ms
51,712 KB
testcase_33 AC 39 ms
51,968 KB
testcase_34 AC 38 ms
51,968 KB
testcase_35 AC 40 ms
51,584 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 621 ms
128,476 KB
testcase_39 AC 38 ms
51,712 KB
testcase_40 AC 566 ms
129,236 KB
testcase_41 AC 38 ms
51,712 KB
testcase_42 AC 38 ms
51,968 KB
testcase_43 AC 39 ms
51,968 KB
testcase_44 AC 38 ms
51,456 KB
testcase_45 AC 38 ms
52,224 KB
testcase_46 AC 38 ms
51,840 KB
testcase_47 AC 40 ms
52,096 KB
testcase_48 AC 165 ms
79,400 KB
testcase_49 WA -
testcase_50 AC 44 ms
59,392 KB
testcase_51 AC 102 ms
79,368 KB
testcase_52 AC 1,648 ms
130,528 KB
testcase_53 AC 142 ms
90,920 KB
testcase_54 AC 184 ms
90,496 KB
testcase_55 AC 321 ms
106,496 KB
testcase_56 AC 225 ms
106,624 KB
testcase_57 AC 38 ms
51,968 KB
testcase_58 AC 224 ms
106,624 KB
testcase_59 AC 562 ms
106,752 KB
testcase_60 AC 52 ms
62,720 KB
testcase_61 AC 253 ms
106,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

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

R = 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 += R[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])
    M = len(combs[k])
    for i in range(M - 1):
        ans = min(ans, abs(rate_sums[combs[k][i]] - rate_sums[combs[k][i + 1]]))
print(ans)
0