This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "cross.h"
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
#define INF 1234567890
#define ll long long
ll res = 0;
vector<pair<int, int> > v;
priority_queue<int> pq;
long long SelectCross(int K, std::vector<int> I, std::vector<int> O) {
int N = I.size();
for (int i = 0; i < N; i++)
v.push_back({ I[i], O[i] });
sort(v.rbegin(), v.rend());
int in_min = INF;
for (int i = 0; i < K; i++)
{
pq.push(-v[i].second);
in_min = min(in_min, v[i].first);
}
res = max(res, 2LL * -pq.top()*in_min - (ll)in_min*in_min);
for (int i = K; i < N; i++)
{
pq.push(-v[i].second);
in_min = min(in_min, v[i].first);
pq.pop();
res = max(res, 2LL * -pq.top()*in_min - (ll)in_min*in_min);
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |