結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー imulanimulan
提出日時 2017-04-22 12:56:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,029 bytes
コンパイル時間 1,644 ms
コンパイル使用メモリ 172,228 KB
実行使用メモリ 8,532 KB
最終ジャッジ日時 2023-09-28 21:16:25
合計ジャッジ時間 7,290 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 2 ms
4,380 KB
testcase_06 RE -
testcase_07 AC 352 ms
8,016 KB
testcase_08 RE -
testcase_09 AC 338 ms
8,052 KB
testcase_10 AC 351 ms
8,168 KB
testcase_11 AC 384 ms
8,316 KB
testcase_12 AC 336 ms
8,012 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 RE -
testcase_20 RE -
権限があれば一括ダウンロードができます

ソースコード

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)
        {
            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