結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー kzyKTkzyKT
提出日時 2016-06-05 21:31:03
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 538 bytes
コンパイル時間 1,473 ms
コンパイル使用メモリ 147,116 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-18 07:30:57
合計ジャッジ時間 3,188 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  int n,k;
  cin >> n >> k;
  int a[n];
  for(int i=0; i<n; i++) cin >> a[i];
  sort(a+1,a+n,greater<int>());
  int l=0,r=n;
  while(l+1!=r) {
    int m=(l+r)/2;
    int l2,r2=n-1,c=0;
    if(r2==m) r2--;
    for(l2=1; l2<r2; l2++,r2--) {
      if(l2==m) continue;
      while(l2<r2&&a[l2]+a[r2]<=a[0]+a[m]) {
        r2--;
        if(r2==m) r2--;
      }
      if(l2>=r2) break;
      c++;
    }
    if(c>=k) r=m;
    else l=m;
  }
  cout << (l?a[l]:-1) << endl;
  return 0;
}
0