結果

問題 No.507 ゲーム大会(チーム決め)
ユーザー azbrugbyazbrugby
提出日時 2019-02-28 20:20:35
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,417 bytes
コンパイル時間 585 ms
コンパイル使用メモリ 76,472 KB
実行使用メモリ 4,452 KB
最終ジャッジ日時 2023-09-05 16:19:41
合計ジャッジ時間 3,028 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 47 ms
4,376 KB
testcase_08 AC 47 ms
4,376 KB
testcase_09 AC 30 ms
4,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <cstdio>
#include <cmath>
#define mk make_pair
#define pb push_back
#define printf printf_s
#define scanf scanf_s
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pos;
const ll MOD = 1000000007, N = 200010, dx[4] = { -1,1,0,0 }, dy[4] = { 0,0,-1,1 }, MIN = -72340172838, MAX = 72340172838;

ll mn(ll a, ll b) {
	if (a == -1)return b;
	if (b == -1)return a;
	return min(a, b);
}
ll gcd(ll v1, ll v2) {
	if (v1 == 0)return v2; if (v2 == 0)return v1; if (v2 > v1)return gcd(v2%v1, v1); return gcd(v1%v2, v2);
}

ll pw(ll v1, ll v2) {
	ll v3 = 1;
	while (v2 > 0) {
		if (v2 % 2)v3 = (v3*v1) % MOD;
		v1 = (v1*v1) % MOD;
		v2 /= 2;
	}
	return v3;
}

struct ab {
	ll a, b;
	bool operator<(const ab& right) const {
		return right.b*a - right.a*b < 0;
	}
};

ll n, m, a[N],av;
int main() {
	cin >> n >> m >> av;
	for (int i = 0; i < n-1; i++)cin >> a[i];
	sort(a, a + n - 1);
	for (int i = 0; i < n-1; i++) {
		if (i < n-1 - m * 2) {
			if (av + a[i] >= a[n-1 - m * 2] + a[n-1 - m * 2 + 1]) {
				cout << a[i] << endl;
				return 0;
			}
		}
		else {
			ll i1 = n - 1 - 2 * m-1, i2 = n - 1 - 2 * m;
			if (i2 == i)i2--;
			if(av+a[i]>=a[i1]+a[i2]) {
				cout << a[i] << endl;
				return 0;
			}
		}
	}
	cout << -1 << endl;
	return 0;
}
0