結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー oxyshoweroxyshower
提出日時 2019-03-21 01:20:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 619 bytes
コンパイル時間 1,795 ms
コンパイル使用メモリ 172,704 KB
実行使用メモリ 4,796 KB
最終ジャッジ日時 2023-10-19 04:39:08
合計ジャッジ時間 3,494 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,348 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 21 ms
4,348 KB
testcase_08 AC 22 ms
4,348 KB
testcase_09 AC 12 ms
4,348 KB
testcase_10 AC 13 ms
4,532 KB
testcase_11 AC 12 ms
4,796 KB
testcase_12 AC 12 ms
4,348 KB
testcase_13 WA -
testcase_14 WA -
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 int long long

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n,m; cin >> n >> m;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  sort(a.begin()+1,a.end());
  if(n == m*2){
    cout << a[1] << endl;
    return 0;
  }
  vector<int> rival(m*2);
  for(int i = 0; i < n; i++){
    if(i >= m*2) break;
    rival[i] = a[n-1 - i];
  }
  int need = rival[0] + rival[m*2-1] - a[0];
  for(int i = 1; i < n-m*2; i++){
    if(a[i] >= need){
      cout << a[i] << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}
0