結果

問題 No.2918 Divide Applicants Fairly
ユーザー ゆにたりー卿
提出日時 2024-09-23 19:19:22
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 608 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 124 ms
コンパイル使用メモリ 85,248 KB
実行使用メモリ 121,728 KB
最終ジャッジ日時 2026-04-24 02:41:48
合計ジャッジ時間 9,058 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 23 WA * 38
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from math import factorial

N = int(input())

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

rates = list(map(int, input().split()))
rate_sums = list(range(factorial(N) // factorial(N // 2) // factorial(N - N // 2)))

i = 0
for comb in range(1, 1 << N):
    if comb.bit_count() != N // 2:
        continue
    
    rate_sum = 0
    for i in range(N):
        if (comb >> i) & 1: rate_sum += rates[i]
    rate_sums[i] = rate_sum
    i += 1
rate_sums.sort()

ans = 2 ** 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)
0