結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー vjudge1
提出日時 2025-02-23 12:39:37
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 701 bytes
コンパイル時間 1,865 ms
コンパイル使用メモリ 162,336 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-02-23 12:39:41
合計ジャッジ時間 3,148 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#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(l<=r) {
            if(a[l]+a[r]>a[1]+a[x]) cnt++,r--;
            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,a[0]=-1;
    for(int i=1;i<=n;i++) std::cin>>a[i];
    std::sort(a+2,a+n+1); int l=2,r=n,ans=0;
    while(l<=r) {
        int m=(l+r)>>1;
        if(check(m)) ans=m,r=m-1;
        else l=m+1;
    }
    std::cout<<a[ans];
    return 0;
}
0