結果
問題 |
No.507 ゲーム大会(チーム決め)
|
ユーザー |
![]() |
提出日時 | 2025-02-23 10:22:10 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 668 bytes |
コンパイル時間 | 1,302 ms |
コンパイル使用メモリ | 157,880 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2025-02-23 10:22:13 |
合計ジャッジ時間 | 2,681 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 8 WA * 11 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 100010; int n, m; int a[N]; bool check(int mid) { int t = a[mid] + a[1] + 1, res = 0, tt = n; for (int i = 2; i <= tt; i ++ ) { if (i == mid) continue; if (tt == mid) tt -- ; if (a[i] + a[tt] >= t) res ++ , tt -- ; } return res < m; } signed main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m; a[n + 1] = -1; for (int i = 1; i <= n; i ++ ) cin >> a[i]; sort(a + 2, a + n + 1); int l = 2, r = n, res = n + 1; while (l <= r) { int mid = l + r >> 1; if (check(mid)) r = mid - 1, res = mid; else l = mid + 1; } cout << a[res]; return 0; }