結果
| 問題 |
No.507 ゲーム大会(チーム決め)
|
| コンテスト | |
| ユーザー |
mkawa2
|
| 提出日時 | 2020-05-21 16:27:31 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 286 ms / 3,000 ms |
| コード長 | 1,238 bytes |
| コンパイル時間 | 106 ms |
| コンパイル使用メモリ | 12,800 KB |
| 実行使用メモリ | 15,232 KB |
| 最終ジャッジ日時 | 2024-10-02 00:04:12 |
| 合計ジャッジ時間 | 4,046 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 19 |
ソースコード
from operator import itemgetter
from itertools import *
from bisect import *
from collections import *
from heapq import *
import sys
sys.setrecursionlimit(10 ** 6)
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def SI(): return sys.stdin.readline()[:-1]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
int1 = lambda x: int(x) - 1
def MI1(): return map(int1, sys.stdin.readline().split())
def LI1(): return list(map(int1, sys.stdin.readline().split()))
p2D = lambda x: print(*x, sep="\n")
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]
def main():
n,m=MI()
a0=II()
aa=[II() for _ in range(n-1)]
aa.sort()
def ok(i):
s=a0+aa[i]
cnt=0
j0=0
for j1 in range(n-2,-1,-1):
if j1==i:continue
while (aa[j0]+aa[j1]<=s or j0==i) and j0<j1:j0+=1
if j1<=j0:break
cnt+=1
j0+=1
return cnt<m
l=-1
r=n-1
while l+1<r:
i=(l+r)//2
if ok(i):r=i
else:l=i
if r==n-1:print(-1)
else:print(aa[r])
main()
mkawa2