結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー imulanimulan
提出日時 2017-04-22 12:57:26
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 382 ms / 3,000 ms
コード長 1,033 bytes
コンパイル時間 1,733 ms
コンパイル使用メモリ 173,876 KB
実行使用メモリ 8,292 KB
最終ジャッジ日時 2023-09-28 21:16:38
合計ジャッジ時間 6,559 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 333 ms
8,292 KB
testcase_08 AC 356 ms
8,152 KB
testcase_09 AC 328 ms
8,020 KB
testcase_10 AC 332 ms
8,168 KB
testcase_11 AC 359 ms
8,120 KB
testcase_12 AC 328 ms
8,168 KB
testcase_13 AC 377 ms
8,020 KB
testcase_14 AC 382 ms
8,020 KB
testcase_15 AC 365 ms
8,292 KB
testcase_16 AC 377 ms
7,984 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int main()
{
    int n,m;
    cin >>n >>m;

    int my;
    cin >>my;

    vector<int> a(n-1);
    rep(i,n-1) cin >>a[i];
    sort(all(a));

    int l=-1,r=n-1;
    while(r-l>1)
    {
        int t=(l+r)/2;
        int score = my + a[t];

        multiset<int> s;
        rep(i,n-1)if(i!=t) s.insert(a[i]);

        int grade=1;
        rep(i,(n-2)/2)
        {
            auto big = s.end();
            --big;

            int A = *big;
            s.erase(big);

            auto itr = s.upper_bound(score-A);

            if(itr == s.end()) break;
            s.erase(itr);
            ++grade;
        }

        if(grade<=m) r=t;
        else l=t;
    }

    if(r==n-1) r=-1;
    else r=a[r];
    cout << r << endl;
    return 0;
}
0