結果
問題 | No.507 ゲーム大会(チーム決め) |
ユーザー |
|
提出日時 | 2019-09-26 21:06:01 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 909 bytes |
コンパイル時間 | 706 ms |
コンパイル使用メモリ | 74,956 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-24 06:21:05 |
合計ジャッジ時間 | 2,252 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 17 WA * 2 |
ソースコード
#include<iostream>#include<vector>#include<algorithm>using namespace std;int main(){int n, m;cin >> n >> m;int k; cin >> k;vector<int> a(n-1);for(int i = 0; i < n-1; i++) cin >> a[i];sort(a.begin(), a.end());auto f = [&](int pos)->bool{int score = a[pos] + k;int count = 0, l = 0, r = n-2;if(l == pos) l++;if(r == pos) r--;while(l < r){if(a[l]+a[r] > score){count++, l++, r--;}else{l++;}if(l == pos) l++;if(r == pos) r--;}return count >= m;};if(f(n-2)){cout << -1 << endl;return 0;}int l = 0, r = n-1;while(r-l > 1){int mid = (l+r)/2;if(f(mid)) l = mid;else r = mid;}cout << a[r] << endl;return 0;}