結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー oevloevl
提出日時 2019-03-21 23:42:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 698 bytes
コンパイル時間 1,942 ms
コンパイル使用メモリ 172,108 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 05:49:22
合計ジャッジ時間 4,006 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;

int main(){
  int N, M, x;
  cin >> N >> M >> x;
  N--;
  vector<int> a(N);
  rep(i, 0, N) cin >> a[i];
  sort(a.begin(), a.end());
  int bl = 0;
  int br = N;
  int mid;
  while(abs(bl - br) > 1) {
    mid = (bl + br) / 2;
    int cnt = 0;
    int l = 0;
    int r = N - 1;
    while(l < r){
      if(l == mid) l++;
      else if(r == mid) r--;
      else if(a[l] + a[r] > x + a[mid]) cnt++, l++, r--;
      else l++;
    }
    if(cnt < M) br = mid;
    else bl = mid;
  }
  cout << (br == N ? -1 : a[br]) << endl;
  return 0;
}
0