#include "cross.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
pii ar[200010];
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();
int i;
for (i=0; i<N; i++) ar[i]={I[i], O[i]};
sort(ar, ar+N);
reverse(ar, ar+N);
for (i=0; i<K; i++) pq.push(ar[i].second);
long long ans=(2*pq.top()-ar[K-1].first)*(ll)ar[K-1].first;
for (i=K; i<N; i++) {
pq.pop();
pq.push(ar[i].second);
ans=max(ans, (2*pq.top()-ar[i].first)*(ll)ar[i].first);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 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 |
11 ms |
640 KB |
Output is correct |
6 |
Correct |
119 ms |
5228 KB |
Output is correct |
7 |
Correct |
115 ms |
5224 KB |
Output is correct |
8 |
Correct |
113 ms |
5100 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 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 |
11 ms |
640 KB |
Output is correct |
6 |
Correct |
119 ms |
5228 KB |
Output is correct |
7 |
Correct |
115 ms |
5224 KB |
Output is correct |
8 |
Correct |
113 ms |
5100 KB |
Output is correct |
9 |
Correct |
5 ms |
128 KB |
Output is correct |
10 |
Correct |
5 ms |
128 KB |
Output is correct |
11 |
Correct |
6 ms |
384 KB |
Output is correct |
12 |
Correct |
20 ms |
640 KB |
Output is correct |
13 |
Correct |
66 ms |
2924 KB |
Output is correct |
14 |
Correct |
114 ms |
5228 KB |
Output is correct |
15 |
Correct |
118 ms |
5224 KB |
Output is correct |
16 |
Correct |
115 ms |
5220 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 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 |
11 ms |
640 KB |
Output is correct |
6 |
Correct |
119 ms |
5228 KB |
Output is correct |
7 |
Correct |
115 ms |
5224 KB |
Output is correct |
8 |
Correct |
113 ms |
5100 KB |
Output is correct |
9 |
Correct |
5 ms |
128 KB |
Output is correct |
10 |
Correct |
5 ms |
128 KB |
Output is correct |
11 |
Correct |
6 ms |
384 KB |
Output is correct |
12 |
Correct |
20 ms |
640 KB |
Output is correct |
13 |
Correct |
66 ms |
2924 KB |
Output is correct |
14 |
Correct |
114 ms |
5228 KB |
Output is correct |
15 |
Correct |
118 ms |
5224 KB |
Output is correct |
16 |
Correct |
115 ms |
5220 KB |
Output is correct |
17 |
Correct |
6 ms |
384 KB |
Output is correct |
18 |
Correct |
6 ms |
432 KB |
Output is correct |
19 |
Correct |
14 ms |
768 KB |
Output is correct |
20 |
Correct |
71 ms |
2928 KB |
Output is correct |
21 |
Correct |
95 ms |
4200 KB |
Output is correct |
22 |
Correct |
121 ms |
5224 KB |
Output is correct |
23 |
Correct |
123 ms |
5224 KB |
Output is correct |
24 |
Correct |
125 ms |
5224 KB |
Output is correct |
25 |
Correct |
121 ms |
6636 KB |
Output is correct |
26 |
Correct |
115 ms |
6632 KB |
Output is correct |