結果
問題 | No.507 ゲーム大会(チーム決め) |
ユーザー |
|
提出日時 | 2019-04-01 02:52:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,375 bytes |
コンパイル時間 | 1,962 ms |
コンパイル使用メモリ | 171,544 KB |
実行使用メモリ | 5,976 KB |
最終ジャッジ日時 | 2024-11-24 01:09:30 |
合計ジャッジ時間 | 3,479 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 14 WA * 5 |
ソースコード
#include <bits/stdc++.h>using namespace std; typedef long double ld; typedef long long ll;typedef unsigned long long ull;#define MP make_pair#define FOR(i,a,b) for(int i=(a);i<=(b);i++)#define FORR(x,arr) for(auto& x:arr)#define VI vector<int>#define PII pair<int, int>#define FI first#define SE second#define ALL(x) (x).begin(), (x).end()const int INF=1<<30; const ll LINF=1LL<<60 ; const ll MOD=1e9+7 ;template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }//-------------------const int MX = 100000 + 7;ll a[MX];int n,m;int r, l;// number of the set whose value is bigger than mine.bool solve(int now){if(now <= 0) return false;ll t = a[0] + a[now];vector<ll> v;FOR(i,1,n-1) if(i != now) v.push_back(a[i]);l = 1; r = v.size()-1;int num = 0;while(l<r){while(v[l]+v[r] <= t && l<r){l++;}if(l<r) {num += 1; l++; r--;}}return num <= m-1;}int main(){cin >> n >> m;FOR(i,0,n-1){cin >> a[i];}sort(a+1, a+n);int R = n-1;for(int i=20;i>=0;i--){if(solve(R-(1<<i))){R -= (1<<i);}}if(R == n-1) cout << -1 << endl;else cout << a[R] << endl;return 0;}