#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 |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
12 ms |
640 KB |
Output is correct |
6 |
Correct |
121 ms |
5772 KB |
Output is correct |
7 |
Correct |
113 ms |
5736 KB |
Output is correct |
8 |
Correct |
107 ms |
5736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
12 ms |
640 KB |
Output is correct |
6 |
Correct |
121 ms |
5772 KB |
Output is correct |
7 |
Correct |
113 ms |
5736 KB |
Output is correct |
8 |
Correct |
107 ms |
5736 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
6 ms |
384 KB |
Output is correct |
12 |
Correct |
11 ms |
768 KB |
Output is correct |
13 |
Correct |
60 ms |
3056 KB |
Output is correct |
14 |
Correct |
108 ms |
5608 KB |
Output is correct |
15 |
Correct |
110 ms |
5736 KB |
Output is correct |
16 |
Correct |
117 ms |
5740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
12 ms |
640 KB |
Output is correct |
6 |
Correct |
121 ms |
5772 KB |
Output is correct |
7 |
Correct |
113 ms |
5736 KB |
Output is correct |
8 |
Correct |
107 ms |
5736 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
6 ms |
384 KB |
Output is correct |
12 |
Correct |
11 ms |
768 KB |
Output is correct |
13 |
Correct |
60 ms |
3056 KB |
Output is correct |
14 |
Correct |
108 ms |
5608 KB |
Output is correct |
15 |
Correct |
110 ms |
5736 KB |
Output is correct |
16 |
Correct |
117 ms |
5740 KB |
Output is correct |
17 |
Correct |
6 ms |
384 KB |
Output is correct |
18 |
Correct |
6 ms |
384 KB |
Output is correct |
19 |
Correct |
13 ms |
896 KB |
Output is correct |
20 |
Correct |
62 ms |
2928 KB |
Output is correct |
21 |
Correct |
91 ms |
5100 KB |
Output is correct |
22 |
Correct |
114 ms |
5740 KB |
Output is correct |
23 |
Correct |
121 ms |
5732 KB |
Output is correct |
24 |
Correct |
118 ms |
5740 KB |
Output is correct |
25 |
Correct |
119 ms |
6628 KB |
Output is correct |
26 |
Correct |
113 ms |
6876 KB |
Output is correct |