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 <bits/stdc++.h>
#include "cross.h"
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
ll calc(ll i, ll o) {
return 2 * o * i - i * i;
}
ll SelectCross(int K, std::vector<int> I, std::vector<int> O) {
int n = (int)I.size();
vector<pair<ll,ll>> c(n);
for (int i = 0; i < n; i++)
c[i] = { I[i],O[i] };
sort(all(c));
reverse(all(c));
priority_queue<ll> q;
for (int i = 0; i < K; i++)
q.push(-c[i].second);
ll ret = calc(c[K - 1].first, -q.top());
for (int i = K; i < n; i++) {
q.push(-c[i].second);
q.pop();
ret = max(ret, calc(c[i].first, -q.top()));
}
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |