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 <algorithm>
#include <queue>
using namespace std;
typedef long long lld;
struct cross {
lld in, ou;
bool operator< (const cross& c) const {
return ou > c.ou;
}
} ba[202020];
priority_queue<lld> pq;
lld SelectCross(int K, vector<int> I, vector<int> O) {
int N=I.size();
for(int i=0; i<N; i++) ba[i].in=I[i], ba[i].ou=O[i];
sort(ba, ba+N);
lld mx=0;
for(int i=0; i<N; i++){
pq.push(-ba[i].in);
if(i>=K) pq.pop();
if(i>=K-1){
lld ii=-pq.top(), oo=ba[i].ou;
if(mx < 2*ii*oo-ii*ii) mx = 2*ii*oo-ii*ii;
}
}
return mx;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |