結果
| 問題 |
No.507 ゲーム大会(チーム決め)
|
| コンテスト | |
| ユーザー |
tubo28
|
| 提出日時 | 2017-06-09 15:24:22 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,401 bytes |
| コンパイル時間 | 2,197 ms |
| コンパイル使用メモリ | 198,220 KB |
| 最終ジャッジ日時 | 2025-01-05 00:39:31 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 6 WA * 10 RE * 3 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
const int MOD = 1000000007;
template <typename T>
void __dump__(std::ostream &os, const T &first) {
os << first;
}
template <typename First, typename... Rest>
void __dump__(std::ostream &os, const First &first, const Rest &... rest) {
os << first << ", ";
__dump__(os, rest...);
}
#define dump(...) \
do { \
std::ostringstream os; \
os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
__dump__(os, __VA_ARGS__); \
std::cerr << os.str() << std::endl; \
} while (0)
int main() {
int n, m;
while (cin >> n >> m) {
int a[100010];
--n;
int x;
cin >> x;
rep(i, n) {
cin >> a[i];
}
// dump("a");
// rep(i, n) cout << a[i] << ' ';
// cout << endl;
int lo = -1, hi = n;
while (lo + 1 < hi) {
int mid = lo + (hi - lo) / 2;
multiset<int> s;
rep(i, n) {
if (i != mid) s.insert(a[i]);
}
auto will_win = [&]() {
if (x < 0) return false;
int our = x + a[mid];
// dump(x, a[mid]);
multiset<int> s;
rep(i, n) if (mid != i) s.insert(a[i]);
rep(i, m) {
int a = *s.rbegin();
s.erase(s.find(a));
// dump(a);
auto bi = s.upper_bound(our - a);
if (bi == s.end()) {
return true;
}
// dump(a, *bi);
s.erase(bi);
}
return false;
};
if (will_win()) {
hi= mid;
} else {
lo = mid;
}
}
int ans = hi == n ? -1 : a[hi];
cout << ans << endl;
}
}
tubo28