結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2017-04-21 23:09:08
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,066 bytes
コンパイル時間 1,344 ms
コンパイル使用メモリ 166,724 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-27 20:41:52
合計ジャッジ時間 2,482 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)



#define INF INT_MAX/2
int N, M, _A[101010], A0; int *A;
//-----------------------------------------------------------------------------------
bool chk(int x) {
    int idx = lower_bound(A, A + N, x) - A;

    int P = A0 + A[idx];
    int cnt = 0;
    int L = 0, R = N - 1;
    while (L < R) {
        if (L == idx) L++;
        else if (R == idx) R--;
        else if (A[L] + A[R] <= P) L++;
        else {
            cnt++;
            L++; R--;
        }
    }

    return cnt < M;
}
//-----------------------------------------------------------------------------------
int main() {
    cin >> N >> M;
    rep(i, 0, N) scanf("%d", &_A[i]);

    A0 = _A[0];
    A = _A + 1; N--;
    sort(A, A + N);

    int lo = 0, hi = A[N - 1] + 1;
    while (lo + 1 != hi) {
        int md = (lo + hi) / 2;
        if (chk(md)) hi = md;
        else lo = md;
    }

    if (hi == A[N - 1] + 1) hi = -1;
    printf("%d\n", hi);

    //cout << chk(1) << endl;
    //cout << chk(2) << endl;
}
0