結果

問題 No.21 平均の差
ユーザー tnodinotnodino
提出日時 2022-02-12 15:54:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,675 ms / 5,000 ms
コード長 701 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 86,996 KB
実行使用メモリ 78,904 KB
最終ジャッジ日時 2023-09-11 03:31:32
合計ジャッジ時間 3,702 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
75,920 KB
testcase_01 AC 305 ms
78,560 KB
testcase_02 AC 1,675 ms
78,904 KB
testcase_03 AC 71 ms
71,360 KB
testcase_04 AC 73 ms
71,328 KB
testcase_05 AC 70 ms
71,344 KB
testcase_06 AC 71 ms
71,384 KB
testcase_07 AC 77 ms
75,052 KB
testcase_08 AC 73 ms
71,324 KB
testcase_09 AC 141 ms
78,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import permutations
N = int(input())
K = int(input())
n = list(int(input()) for _ in range(N))
L = [i for i in range(N)]
ans = 0
for A in range(1,N+1):
    for B in range(1,N+1):
        if N - A - B < K - 2:
            continue
        for X in permutations(L, A):
            for Y in permutations(L, B):
                flg = True
                for x in X:
                    if x in Y:
                        flg = False
                        break
                if flg:
                    P = sum([n[i] for i in X]) / len(X)
                    Q = sum([n[i] for i in Y]) / len(Y)
                    R = int(P - Q + 0.9)
                    ans = max(ans, R)
print(ans)
0