Sat, 09 Feb 2019 21:51:04 GMT
parent
5f59690215
commit
903dd2ff5e
@ -1,8 +1,46 @@
|
|||||||
#define _CRT_SECURE_NO_WARNINGS
|
#define _CRT_SECURE_NO_WARNINGS
|
||||||
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
||||||
#include <bits/stdc++.h>
|
//#include <bits/stdc++.h>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <queue>
|
||||||
|
#include <utility>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
const int N = 1e5 + 50;
|
||||||
|
pair<int, int> a[N];
|
||||||
|
int b[N];
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
int n, c, f;
|
||||||
|
scanf("%d%d%d", &n, &c, &f);
|
||||||
|
for (int i = 0; i < c; i++)
|
||||||
|
scanf("%d%d", &a[i].first, &a[i].second);
|
||||||
|
sort(a, a + c);
|
||||||
|
priority_queue<int> h1, h2;
|
||||||
|
for (int i = 0, x = 0; i < c; i++)
|
||||||
|
{
|
||||||
|
if (i >= (n >> 1))
|
||||||
|
{
|
||||||
|
b[i] += x;
|
||||||
|
if (a[i].second >= h1.top()) continue;
|
||||||
|
x -= h1.top(), h1.pop();
|
||||||
|
}
|
||||||
|
x += a[i].second, h1.push(a[i].second);
|
||||||
|
}
|
||||||
|
for (int i = c - 1, x = 0; i >= 0; i--)
|
||||||
|
{
|
||||||
|
if ((c - i - 1) >= (n >> 1))
|
||||||
|
{
|
||||||
|
b[i] += x;
|
||||||
|
if (a[i].second >= h2.top()) continue;
|
||||||
|
x -= h2.top(), h2.pop();
|
||||||
|
}
|
||||||
|
x += a[i].second, h2.push(a[i].second);
|
||||||
|
}
|
||||||
|
int ans = -1;
|
||||||
|
for (int i = c - 1 - (n >> 1); i >= (n >> 1) && ans == -1; i--)
|
||||||
|
if (b[i] + a[i].second <= f)
|
||||||
|
ans = a[i].first;
|
||||||
|
printf("%d", ans);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Loading…
Reference in new issue