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;
long long SelectCross(int K, std::vector<int> I, std::vector<int> O) {
int N = I.size();
std::pair<long long, long long> soo[N];
for ( int i = 0 ; i < N ; ++i ) {
soo[i] = {O[i], I[i]};
}
sort(soo, soo + N, std::greater< std::pair<long long, long long> >());
std::priority_queue<long long, std::vector<long long>, std::greater<long long>> puts;
for ( int i = 0 ; i < K ; ++i ) {
puts.push(soo[i].second);
}
long long out = soo[K-1].first;
long long in = puts.top();
long long ret = out * out - (out-in) * (out-in);
for ( int i = K ; i < N ; ++i ) {
out = soo[i].first;
puts.pop();
puts.push(soo[i].second);
in = puts.top();
ret = std::max(ret, out * out - (out-in) * (out-in) );
}
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... |