結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー h_nosonh_noson
提出日時 2017-07-12 09:21:09
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 407 ms / 3,000 ms
コード長 1,357 bytes
コンパイル時間 1,061 ms
コンパイル使用メモリ 99,452 KB
実行使用メモリ 13,568 KB
最終ジャッジ日時 2024-04-16 17:49:43
合計ジャッジ時間 5,159 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 320 ms
13,440 KB
testcase_08 AC 362 ms
13,440 KB
testcase_09 AC 145 ms
13,312 KB
testcase_10 AC 228 ms
13,568 KB
testcase_11 AC 254 ms
13,440 KB
testcase_12 AC 139 ms
13,568 KB
testcase_13 AC 397 ms
13,568 KB
testcase_14 AC 377 ms
13,568 KB
testcase_15 AC 395 ms
13,440 KB
testcase_16 AC 407 ms
13,568 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int a[100000];

int main(void) {
    int i, n, m;
    scanf("%d%d",&n,&m);
    REP (i,n) scanf("%d",&a[i]);

    multiset<int> scores;
    REP (i,1,n-1) scores.insert(a[i]);
    sort(a+1,a+n);
    int l = 0, r = n;
    while (l + 1 < r) {
        auto st = scores;
        int mid = (l + r) / 2;
        int score = a[0] + a[mid];
        st.erase(st.lower_bound(a[mid]));
        int cnt;
        REP (cnt,n/2-1) {
            int mx = *(--st.end());
            st.erase(--st.end());
            auto p = st.lower_bound(score - mx + 1);
            if (p == st.end()) break;
            st.erase(p);
        }
        if (m < cnt + 1) {
            l = mid;
        }
        else {
            r = mid;
        }
    }
    if (r == n)
        puts("-1");
    else
        printf("%d\n",a[r]);
    return 0;
}
0