結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー fiordfiord
提出日時 2017-07-12 17:12:24
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 701 bytes
コンパイル時間 687 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 82,816 KB
最終ジャッジ日時 2024-04-16 17:51:23
合計ジャッジ時間 3,127 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
52,224 KB
testcase_01 AC 41 ms
52,096 KB
testcase_02 AC 41 ms
52,096 KB
testcase_03 AC 41 ms
52,608 KB
testcase_04 AC 41 ms
52,224 KB
testcase_05 AC 40 ms
52,096 KB
testcase_06 AC 41 ms
52,224 KB
testcase_07 AC 134 ms
81,664 KB
testcase_08 AC 152 ms
82,560 KB
testcase_09 AC 141 ms
81,152 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 41 ms
52,480 KB
testcase_18 WA -
testcase_19 AC 41 ms
51,968 KB
testcase_20 AC 41 ms
52,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
n, m = map(int, input().split())
a0 = int(input())
a = [int(input()) for x in range(n - 1)]
a.sort()
#-1 check
l = 0
r = n - 3
cnt = 0
while l < r:
	while l < r and a[l] + a[r] <= a[n - 2] + a0:
		l += 1
	if l < r:
		l += 1
		r -= 1
		cnt += 1
if cnt >= m:
	print(-1)
	sys.exit(0)
low = 0
high = n - 2
for i in range(50):
	mid = int((low + high) / 2)
	l = 0
	r = n - 2
	cnt=0
	while l < mid and mid < r:
		while l < mid and a[l] + a[r] <= a[mid] + a0:
			l += 1
		if l<mid:
			l += 1
			r -= 1
			cnt += 1
	while mid + 1 < r and a[r-1]+a[r]>a[mid]+a0:
		r -= 2
		cnt += 1
	while l+1<mid and a[l]+a[l+1]>a[mid]+a0:
		l+=2
		cnt+=1
	if cnt >= m:
		low = mid
	else:
		high = mid
print(a[high])
0