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];
lld ent[202020], cnt;
lld SelectCross(int N, int K, vector<int> I, vector<int> O) {
for(int i=0; i<N; i++) ba[i].in=I[i], ba[i].ou=O[i];
sort(ba, ba+N);
lld mx=0; cnt=0;
for(int i=0; i<N; i++){
ent[cnt++]=-ba[i].in; sort(ent, ent+cnt);
if(i>=K) cnt--;
if(i>=K-1){
lld ii=-ent[cnt-1], 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... |