結果
問題 |
No.507 ゲーム大会(チーム決め)
|
ユーザー |
![]() |
提出日時 | 2025-02-28 20:58:45 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 21 ms / 3,000 ms |
コード長 | 598 bytes |
コンパイル時間 | 3,030 ms |
コンパイル使用メモリ | 276,092 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-02-28 20:58:50 |
合計ジャッジ時間 | 4,571 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 19 |
ソースコード
#include<bits/stdc++.h> #define int long long #define maxn 100005 using namespace std; int n,a[maxn],xm,ans,m;bool vis[maxn]; inline bool check(int x){ int tot=0,res=xm+a[x],now=1; for(int i=n;i>=1;--i){ if(i==x)continue; while(a[now]+a[i]<=res&&now<i||now==x)now++; if(now>=i)break; ++tot;++now; } return tot<m; } signed main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>n>>m>>xm;--n;a[0]=-1; for(int i=1;i<=n;++i)cin>>a[i];sort(a+1,a+1+n); int L=1,R=n,mid; while(L<=R){ mid=(L+R)>>1; if(check(mid))ans=mid,R=mid-1; else L=mid+1; } cout<<a[ans]; return 0; }