結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー task4233task4233
提出日時 2019-01-01 22:03:54
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,033 bytes
コンパイル時間 2,433 ms
コンパイル使用メモリ 163,268 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-25 21:09:42
合計ジャッジ時間 2,674 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 2 ms
6,940 KB
testcase_06 WA -
testcase_07 AC 45 ms
6,944 KB
testcase_08 WA -
testcase_09 AC 28 ms
6,948 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
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;

int main() {
  int n, m, t;
  cin >> n >> m >> t;
  vector< int > a(n-1);
  for (int i=0; i<n-1; ++i) cin >> a[i];
  sort(a.begin(), a.end());

  vector< int > sm;
  for (int i=0; i<m-1; ++i) {
    int tmp = a[n-i*2-2] + a[n-i*2-3];
    sm.push_back(tmp);
  }
  if (!sm.empty()) sort(sm.begin(), sm.end());
  else {
    if (t+a[n-4] < a[n-3] + a[n-2]) cout << -1 << endl;
    else cout << (a[n-3]+a[n-2]-t) << endl;
    return 0;
  }
  // cout << sm[0] - t << endl;
  
  auto check = [&](int s) {
    int d = sm[0] - t;
    return d <= s;
  };

  // 上位M位に入るために, 最低何点までならばおkか?
  // 上位M-1組を組ませてから自分の組を組めば良い。
  // 最低の点数をs点とすると, 上位m-1組を組ませてからおkかを考えればよい。
  // にぶたん だ, [ng, ok).
  int ng = 0, ok = 1e9;
  while (ok-ng > 1) {
    int mid = (ok+ng)/2;
    (check(mid)?ok:ng) = mid;
  }
  int ans = ok;
  cout << ans << endl;
  return 0;
}
0