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>
#define sz(v) ((int)(v).size())
using namespace std;
using pi = pair<int, int>;
using lint = long long;
const int MAXN = 200005;
int N;
lint X[MAXN], Y[MAXN];
lint func(lint X, lint Y){
return 2 * X * Y - X * X;
}
long long SelectCross(int K, std::vector<int> I, std::vector<int> O) {
N = I.size();
vector<pi> v, A;
for(int i=0; i<N; i++) v.emplace_back(I[i], O[i]);
sort(v.begin(), v.end());
reverse(v.begin(), v.end());
priority_queue<int, vector<int>, greater<int> > pq;
lint ret = 0;
for(int i=0; i<sz(v); ){
int e = i;
while(e < sz(v) && v[i].first == v[e].first) e++;
for(int j=i; j<e; j++) pq.push(v[j].second);
while(sz(pq) > K) pq.pop();
if(sz(pq) == K) ret = max(ret, func(v[i].first, pq.top()));
i = e;
}
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... |