結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー ckawatakckawatak
提出日時 2019-01-12 17:35:27
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 600 bytes
コンパイル時間 721 ms
コンパイル使用メモリ 87,208 KB
実行使用メモリ 86,696 KB
最終ジャッジ日時 2023-08-23 11:08:48
合計ジャッジ時間 6,231 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,100 KB
testcase_01 AC 73 ms
71,016 KB
testcase_02 AC 68 ms
70,968 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 69 ms
70,976 KB
testcase_06 WA -
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N, M = list(map(int, input().split(' ')))

A = []
for i in range(N):
    A.append(int(input()))

K = A[0]    
A = sorted(A, reverse=True)
used = [False for _ in range(len(A))]
done = 0

for i in range(len(A)-2):
    for j in reversed(range(len(A))):
        if not used[j]:
            x = A[i] + A[j]
            y = A[i+1] + A[i+2]
            if y <= x:
                if (A[i] == K or A[j] == K) and done < M:
                    print(x - K)
                    exit(0)
                else:
                    done = done + 1
                    used[j] = True

print(-1)                    
0