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 <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
long long SelectCross(int k, std::vector<int> I, std::vector<int> O) {
int n = I.size();
vector<pii> v;
for(int i=0;i<n;i++) {
v.push_back(pii(O[i], I[i]));
}
sort(v.begin(), v.end());
priority_queue<int> pq;
for(int i=n-k;i<n;i++) {
pq.push(-v[i].second);
}
ll ret = (ll)v[n-k].first * v[n-k].first - (ll)(v[n-k].first + pq.top()) * (v[n-k].first + pq.top());
for(int i=n-k-1;i>=0;i--) {
if(-v[i].second <= pq.top()) {
pq.pop();
pq.push(-v[i].second);
}
ret = max(ret, (ll)v[i].first * v[i].first - (ll)(v[i].first + pq.top()) * (v[i].first + pq.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... |