結果
| 問題 | No.507 ゲーム大会(チーム決め) | 
| コンテスト | |
| ユーザー |  vjudge1 | 
| 提出日時 | 2025-02-23 12:36:39 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 696 bytes | 
| コンパイル時間 | 1,560 ms | 
| コンパイル使用メモリ | 163,176 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2025-02-23 12:36:42 | 
| 合計ジャッジ時間 | 3,061 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 4 WA * 15 | 
ソースコード
#include<bits/stdc++.h>
//#define DEBUG
const int N=1e5+10; int n,m,a[N];
bool check(int x) {
    int cnt=0,l=2,r=n;
    while(l<=r) {
        if(l==x) l++;
        if(r==x) r--;
        if(a[l]+a[r]>a[1]+a[x]) cnt++,r--;
        else l++;
    }
    return cnt<m;
}
int main() {
    //freopen("prize.in","r",stdin);
    //freopen("prize.out","w",stdout);
    std::ios::sync_with_stdio(false),std::cin.tie(nullptr);
    std::cin>>n>>m;
    for(int i=1;i<=n;i++) std::cin>>a[i];
    std::sort(a+2,a+n+1); int l=2,r=n,ans=-1;
    while(l<=r) {
        int m=(l+r)>>1;
        if(check(m)) ans=m,r=m-1;
        else l=m+1;
    }
    if(~ans) std::cout<<a[ans];
    else std::cout<<-1;
    return 0;
}
            
            
            
        