結果
問題 | No.507 ゲーム大会(チーム決め) |
ユーザー | roaris |
提出日時 | 2019-11-08 15:22:53 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 692 bytes |
コンパイル時間 | 363 ms |
コンパイル使用メモリ | 86,988 KB |
実行使用メモリ | 182,776 KB |
最終ジャッジ日時 | 2023-10-13 03:12:12 |
合計ジャッジ時間 | 5,296 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 75 ms
71,328 KB |
testcase_01 | AC | 73 ms
71,580 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 195 ms
157,940 KB |
testcase_08 | WA | - |
testcase_09 | AC | 181 ms
176,528 KB |
testcase_10 | AC | 168 ms
145,800 KB |
testcase_11 | AC | 162 ms
133,420 KB |
testcase_12 | AC | 184 ms
176,652 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
ソースコード
import sys input = sys.stdin.readline def judge(x): p = a0+a[x] b = [a[i] for i in range(N-1) if i != x] pair = 0 l, r = 0, N-3 while l <= r: if b[l]+b[r] >= p+1: pair += 1 r -= 1 l += 1 return pair <= M-1 def binary_search(): left, right = 0, N-2 while left <= right: mid = (left+right)//2 if judge(mid): right = mid-1 else: left = mid+1 return left N, M = map(int, input().split()) a0 = int(input()) a = [int(input()) for _ in range(N-1)] a.sort() ans = binary_search() if ans == N-1: print(-1) else: print(ans)