結果
| 問題 |
No.507 ゲーム大会(チーム決め)
|
| コンテスト | |
| ユーザー |
WA_TLE
|
| 提出日時 | 2017-04-21 23:30:06 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,204 bytes |
| コンパイル時間 | 510 ms |
| コンパイル使用メモリ | 51,072 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-20 17:47:14 |
| 合計ジャッジ時間 | 1,686 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 WA * 1 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:20:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | scanf("%d %d",&N,&M);
| ~~~~~^~~~~~~~~~~~~~~
main.cpp:23:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
23 | scanf("%d",&me);
| ~~~~~^~~~~~~~~~
main.cpp:25:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
25 | scanf("%d",&q);
| ~~~~~^~~~~~~~~
ソースコード
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
//#define scanf scanf_s
#define fir first
#define sec second
#define mp make_pair
#define mt make_tuple
#define pub push_back
using namespace std;
typedef long long int llint;
const llint one = 1;
const llint big = (one<<30);
const int mod=1000000007;
inline int gcd(int a,int b) { return b ? gcd(b, a % b) : a; }
int main(void){
int N,M,me,q,gen=0,bmax,bmin,can;
vector<int> po;
scanf("%d %d",&N,&M);
bmax=N-1;
bmin=-1;
scanf("%d",&me);
for(int i=1;i<N;i++){
scanf("%d",&q);
po.pub(q);
}
sort(po.rbegin(),po.rend());
//ペアの相手の順位を最大化
//8 2
//4
//6
//5
//4
//3
//2
//1
//1
while(bmax-bmin>1){
gen=(bmax+bmin)/2;
int dow=N-2,lead=0,tei=me+po[gen],ok=1,it=0;
for(lead=0;lead<M+it;lead++){
if(lead==gen){it++;continue;}
for(;dow>=0;dow--){
if(dow==gen){continue;}
if(dow<M+it){ok=0;break; }
if(po[dow]+po[lead]>tei){dow--;break;}
}
if(ok==0){break;}
}
if(ok==1){bmax=gen;}//gen位の人と組んで敗退
else{bmin=gen;}
}
if(bmin==-1){gen=-1;}
else{gen=(bmax+bmin)/2;}
if(gen==-1){printf("-1\n");}
else{printf("%d\n",po[gen]);}
return 0;
}
WA_TLE