結果
問題 |
No.507 ゲーム大会(チーム決め)
|
ユーザー |
![]() |
提出日時 | 2025-02-23 15:45:50 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 23 ms / 3,000 ms |
コード長 | 1,030 bytes |
コンパイル時間 | 1,807 ms |
コンパイル使用メモリ | 198,140 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-02-23 15:46:02 |
合計ジャッジ時間 | 2,908 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 19 |
ソースコード
#include<bits/stdc++.h> using namespace std; inline int read(){ int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0'&&ch<='9'){ x=x*10+ch-48; ch=getchar(); } return x*f; } int n,m,k; int a[101010]; int check(int x){ if(x<0) return 0; int t=k+a[x]; vector<int> v; int i; for(int i=0;i<n;i++){ if(i!=x) v.push_back(a[i]); } int ret=0; int l=0,r=v.size()-1; while(l<r){ while(l<r && v[r]+v[l]<=t) l++; if(l>=r) break; ret++; l++,r--; } return ret<m; } signed main(){ // freopen("","r",stdin); // freopen("","w",stdout); cin>>n>>m; cin>>k; for(int i=0;i<n-1;i++){ a[i]=read(); } n--; sort(a,a+n); int x=n-1; if(check(x)==0){ printf("-1\n"); return 0; } for(int i=20;i>=0;i--){ if(check(x-(1<<i))){ x-=1<<i; } } cout<<a[x]<<endl; return 0; }