結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー kotatsugamekotatsugame
提出日時 2019-11-19 02:14:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 62 ms / 3,000 ms
コード長 532 bytes
コンパイル時間 1,176 ms
コンパイル使用メモリ 76,488 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 08:08:33
合計ジャッジ時間 2,863 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 50 ms
6,940 KB
testcase_08 AC 50 ms
6,940 KB
testcase_09 AC 31 ms
6,944 KB
testcase_10 AC 37 ms
6,944 KB
testcase_11 AC 42 ms
6,940 KB
testcase_12 AC 31 ms
6,940 KB
testcase_13 AC 62 ms
6,944 KB
testcase_14 AC 49 ms
6,944 KB
testcase_15 AC 49 ms
6,940 KB
testcase_16 AC 50 ms
6,944 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N,M;
int A[1<<17];
main()
{
	cin>>N>>M;
	for(int i=0;i<N;i++)cin>>A[i];
	sort(A+1,A+N);
	if(N/2==M)
	{
		cout<<A[1]<<endl;
		return 0;
	}
	int L=0,R=N;
	while(R-L>1)
	{
		int mid=(L+R)/2;
		int K=A[0]+A[mid];
		vector<int>X;
		int id=N-1;
		while(X.size()<2*M)
		{
			if(id==mid)id--;
			X.push_back(A[id]);
			id--;
		}
		bool flag=true;
		for(int i=0;i<M;i++)flag&=K<X[i]+X[2*M-i-1];
		if(flag)L=mid;
		else R=mid;
	}
	cout<<(R==N?-1:A[R])<<endl;
}
0