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 <bits/stdc++.h>
using namespace std;
#include "cross.h"
struct pos
{
int x, y;
bool operator <(const pos &a) const
{
return x != a.x ? x > a.x : y > a.y;
}
};
long long SelectCross(int k, std::vector<int> I, std::vector<int> O) {
int n = I.size(), i;
vector<pos> v;
for(i = 0; i < n; i++)
v.push_back({ O[i], I[i] });
sort(v.begin(), v.end());
long long res = 0;
priority_queue<int> pq;
for(i = 0; i < n; i++)
{
pq.push(-v[i].y);
while((int)pq.size() > k)
pq.pop();
if((int)pq.size() == k)
{
int x = v[i].x;
int y = -pq.top();
long long cur = 2LL * x * y - 1LL * y * y;
res = max(res, cur);
}
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |