#include "cross.h"
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
ll ans,in,out;
pii C[200005];
priority_queue<int, vector<int>, greater<int> > PQ;
long long SelectCross(int K, std::vector<int> I, std::vector<int> O) {
int N = I.size();
for(int i=0; i<N; i++){
C[i].va = O[i];
C[i].vb = I[i];
}
sort(C,C+N);
out = C[N-K].va;
for(int i=N-K; i<N; i++) PQ.push(C[i].vb);
in = PQ.top();
ans = 2*in*out-in*in;
for(int i=N-K-1; i>=0; i--){
out = C[i].va;
PQ.pop();
PQ.push(C[i].vb);
in = PQ.top();
ans = max(ans,2*in*out-in*in);
//cout << in << out << ans << '\n';
}
return ans;
}
# |
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 |
13 ms |
512 KB |
Output is correct |
6 |
Correct |
113 ms |
5224 KB |
Output is correct |
7 |
Correct |
115 ms |
5228 KB |
Output is correct |
8 |
Correct |
115 ms |
5224 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 |
13 ms |
512 KB |
Output is correct |
6 |
Correct |
113 ms |
5224 KB |
Output is correct |
7 |
Correct |
115 ms |
5228 KB |
Output is correct |
8 |
Correct |
115 ms |
5224 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 |
13 ms |
640 KB |
Output is correct |
13 |
Correct |
61 ms |
2928 KB |
Output is correct |
14 |
Correct |
118 ms |
5228 KB |
Output is correct |
15 |
Correct |
120 ms |
5224 KB |
Output is correct |
16 |
Correct |
120 ms |
5224 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 |
13 ms |
512 KB |
Output is correct |
6 |
Correct |
113 ms |
5224 KB |
Output is correct |
7 |
Correct |
115 ms |
5228 KB |
Output is correct |
8 |
Correct |
115 ms |
5224 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 |
13 ms |
640 KB |
Output is correct |
13 |
Correct |
61 ms |
2928 KB |
Output is correct |
14 |
Correct |
118 ms |
5228 KB |
Output is correct |
15 |
Correct |
120 ms |
5224 KB |
Output is correct |
16 |
Correct |
120 ms |
5224 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
6 ms |
384 KB |
Output is correct |
19 |
Correct |
13 ms |
768 KB |
Output is correct |
20 |
Correct |
66 ms |
2932 KB |
Output is correct |
21 |
Correct |
95 ms |
4204 KB |
Output is correct |
22 |
Correct |
116 ms |
5224 KB |
Output is correct |
23 |
Correct |
121 ms |
5148 KB |
Output is correct |
24 |
Correct |
130 ms |
5352 KB |
Output is correct |
25 |
Correct |
123 ms |
6500 KB |
Output is correct |
26 |
Correct |
118 ms |
6508 KB |
Output is correct |