結果
| 問題 |
No.507 ゲーム大会(チーム決め)
|
| コンテスト | |
| ユーザー |
ei1333333
|
| 提出日時 | 2017-04-21 23:07:44 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 825 bytes |
| コンパイル時間 | 1,379 ms |
| コンパイル使用メモリ | 161,884 KB |
| 実行使用メモリ | 8,448 KB |
| 最終ジャッジ日時 | 2024-07-20 15:14:53 |
| 合計ジャッジ時間 | 4,037 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 2 WA * 14 RE * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
int N, M, K, A[100000];
bool check(int idx)
{
multiset< int > vv;
for(int i = 0; i < N; i++) {
if(i != idx) vv.emplace(A[i]);
}
int64 beet = A[idx] + K;
multiset< int >::iterator it = vv.begin();
int ret = 0;
while(it != vv.end()) {
auto st = vv.upper_bound(beet - A[*it]);
if(it == st) ++st;
if(st != vv.end()) vv.erase(st), ++ret;
it = vv.erase(it);
}
return (ret < M);
}
int main()
{
cin >> N >> M;
--N;
cin >> K;
for(int i = 0; i < N; i++) cin >> A[i];
if(!check(A[N - 1])) {
cout << -1 << endl;
return (0);
}
int low = 0, high = N - 1;
while(high - low > 0) {
int mid = (low + high) / 2;
if(check(mid)) high = mid;
else low = mid + 1;
}
cout << A[low] << endl;
}
ei1333333