이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |