結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー furafura
提出日時 2020-07-31 03:52:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 479 bytes
コンパイル時間 2,080 ms
コンパイル使用メモリ 202,632 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-18 17:27:42
合計ジャッジ時間 4,128 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 24 ms
4,376 KB
testcase_08 AC 23 ms
4,380 KB
testcase_09 AC 15 ms
4,376 KB
testcase_10 AC 15 ms
4,376 KB
testcase_11 AC 15 ms
4,376 KB
testcase_12 AC 15 ms
4,380 KB
testcase_13 AC 23 ms
4,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

int main(){
	int n,m; scanf("%d%d",&n,&m);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	sort(a.begin()+1,a.end());
	int lo=0,hi=n;
	while(hi-lo>1){
		int mi=(lo+hi)/2;

		int sum=a[0]+a[mi],cnt=0;
		for(int i=1,j=n-1;;i++,j--){
			while(i<j && a[i]+a[j]<=sum) i++;
			if(i>=j) break;
			cnt++;
		}
		if(cnt<m) hi=mi;
		else      lo=mi;
	}
	printf("%d\n",hi==n?-1:a[hi]);

	return 0;
}
0