#include "cross.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
long long SelectCross(int k, std::vector<int> a, std::vector<int> b) {
vector<pair<int,int> > x;
multiset<int> r;
for(int i = 0; i < (int)a.size(); i++){
x.push_back({a[i], b[i]});
}
sort(x.begin(), x.end());
reverse(x.begin(), x.end());
ll ans = 0;
multiset<int> bb;
for(pair<int,int> p : x){
bb.insert(p.second);
while((int)bb.size() > k) bb.erase(bb.begin());
if((int)bb.size() == k){
ll A = p.first;
ll B = *bb.begin();
ans = max(ans, 2 * A * B - A * A);
}
}
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 |
5 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 |
122 ms |
5740 KB |
Output is correct |
7 |
Correct |
122 ms |
5740 KB |
Output is correct |
8 |
Correct |
121 ms |
5484 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 |
5 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 |
122 ms |
5740 KB |
Output is correct |
7 |
Correct |
122 ms |
5740 KB |
Output is correct |
8 |
Correct |
121 ms |
5484 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 |
768 KB |
Output is correct |
13 |
Correct |
66 ms |
3056 KB |
Output is correct |
14 |
Correct |
126 ms |
5736 KB |
Output is correct |
15 |
Correct |
125 ms |
5740 KB |
Output is correct |
16 |
Correct |
126 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 |
5 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 |
122 ms |
5740 KB |
Output is correct |
7 |
Correct |
122 ms |
5740 KB |
Output is correct |
8 |
Correct |
121 ms |
5484 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 |
768 KB |
Output is correct |
13 |
Correct |
66 ms |
3056 KB |
Output is correct |
14 |
Correct |
126 ms |
5736 KB |
Output is correct |
15 |
Correct |
125 ms |
5740 KB |
Output is correct |
16 |
Correct |
126 ms |
5740 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
6 ms |
256 KB |
Output is correct |
19 |
Correct |
16 ms |
1280 KB |
Output is correct |
20 |
Correct |
73 ms |
3052 KB |
Output is correct |
21 |
Correct |
98 ms |
5068 KB |
Output is correct |
22 |
Correct |
129 ms |
5736 KB |
Output is correct |
23 |
Correct |
128 ms |
5736 KB |
Output is correct |
24 |
Correct |
147 ms |
6364 KB |
Output is correct |
25 |
Correct |
212 ms |
11240 KB |
Output is correct |
26 |
Correct |
259 ms |
14436 KB |
Output is correct |