#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 |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
13 ms |
768 KB |
Output is correct |
6 |
Correct |
115 ms |
5736 KB |
Output is correct |
7 |
Correct |
111 ms |
5740 KB |
Output is correct |
8 |
Correct |
112 ms |
5740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
13 ms |
768 KB |
Output is correct |
6 |
Correct |
115 ms |
5736 KB |
Output is correct |
7 |
Correct |
111 ms |
5740 KB |
Output is correct |
8 |
Correct |
112 ms |
5740 KB |
Output is correct |
9 |
Correct |
5 ms |
304 KB |
Output is correct |
10 |
Correct |
6 ms |
384 KB |
Output is correct |
11 |
Correct |
6 ms |
384 KB |
Output is correct |
12 |
Correct |
12 ms |
768 KB |
Output is correct |
13 |
Correct |
59 ms |
3188 KB |
Output is correct |
14 |
Correct |
111 ms |
5732 KB |
Output is correct |
15 |
Correct |
117 ms |
5736 KB |
Output is correct |
16 |
Correct |
117 ms |
5740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
256 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
13 ms |
768 KB |
Output is correct |
6 |
Correct |
115 ms |
5736 KB |
Output is correct |
7 |
Correct |
111 ms |
5740 KB |
Output is correct |
8 |
Correct |
112 ms |
5740 KB |
Output is correct |
9 |
Correct |
5 ms |
304 KB |
Output is correct |
10 |
Correct |
6 ms |
384 KB |
Output is correct |
11 |
Correct |
6 ms |
384 KB |
Output is correct |
12 |
Correct |
12 ms |
768 KB |
Output is correct |
13 |
Correct |
59 ms |
3188 KB |
Output is correct |
14 |
Correct |
111 ms |
5732 KB |
Output is correct |
15 |
Correct |
117 ms |
5736 KB |
Output is correct |
16 |
Correct |
117 ms |
5740 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
6 ms |
384 KB |
Output is correct |
19 |
Correct |
12 ms |
896 KB |
Output is correct |
20 |
Correct |
63 ms |
3184 KB |
Output is correct |
21 |
Correct |
90 ms |
5100 KB |
Output is correct |
22 |
Correct |
115 ms |
5480 KB |
Output is correct |
23 |
Correct |
124 ms |
5744 KB |
Output is correct |
24 |
Correct |
127 ms |
5740 KB |
Output is correct |
25 |
Correct |
121 ms |
6632 KB |
Output is correct |
26 |
Correct |
113 ms |
6876 KB |
Output is correct |