結果
| 問題 |
No.507 ゲーム大会(チーム決め)
|
| コンテスト | |
| ユーザー |
vwxyz
|
| 提出日時 | 2022-06-21 11:01:47 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 659 bytes |
| コンパイル時間 | 97 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 15,648 KB |
| 最終ジャッジ日時 | 2024-10-14 04:24:32 |
| 合計ジャッジ時間 | 7,370 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 2 WA * 17 |
ソースコード
import sys
readline=sys.stdin.readline
def Bisect_Int(ok,ng,is_ok):
while abs(ok-ng)>1:
mid=(ok+ng)//2
if is_ok(mid):
ok=mid
else:
ng=mid
return ok
N,M=map(int,readline().split())
a=int(readline())
A=[int(readline()) for i in range(N-1)]
A.sort()
def is_ok(i):
if i==N-1:
return True
AA=[A[ii] for ii in range(N-1) if i!=ii]
cnt=0
l,r=0,N-2
while l<r:
while l+1<r and A[l]+A[r]<=a+A[i]:
l+=1
if l<r and A[l]+A[r]>a+A[i]:
cnt+=1
l+=1
r-=1
return cnt<M
ans=Bisect_Int(N-1,0,is_ok)
if ans==N-1:
ans=-1
print(ans)
vwxyz