#include "cross.h"
#include <bits/stdc++.h>
using namespace std;
long long SelectCross(int k, std::vector<int> a, std::vector<int> b) {
int n = (int)a.size();
pair<int, int> c[200005] = {};
for (int i = 0; i < n; i++) c[i] = {b[i], a[i]};
sort(c, c + n); reverse(c, c + n);
multiset<int> s;
for (int i = 0; i < k; i++) s.insert(c[i].second);
long long z = 1ll * c[k - 1].first * c[k - 1].first - 1ll * (c[k - 1].first - *s.begin()) * (c[k - 1].first - *s.begin());
for (int i = k; i < n; i++) {
s.insert(c[i].second);
s.erase(s.find(*s.begin()));
z = max(z, 1ll * c[i].first * c[i].first - 1ll * (c[i].first - *s.begin()) * (c[i].first - *s.begin()));
}
return z;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1920 KB |
Output is correct |
2 |
Correct |
6 ms |
1920 KB |
Output is correct |
3 |
Correct |
6 ms |
1920 KB |
Output is correct |
4 |
Correct |
7 ms |
1920 KB |
Output is correct |
5 |
Correct |
14 ms |
2176 KB |
Output is correct |
6 |
Correct |
124 ms |
5224 KB |
Output is correct |
7 |
Correct |
125 ms |
5224 KB |
Output is correct |
8 |
Correct |
130 ms |
5224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1920 KB |
Output is correct |
2 |
Correct |
6 ms |
1920 KB |
Output is correct |
3 |
Correct |
6 ms |
1920 KB |
Output is correct |
4 |
Correct |
7 ms |
1920 KB |
Output is correct |
5 |
Correct |
14 ms |
2176 KB |
Output is correct |
6 |
Correct |
124 ms |
5224 KB |
Output is correct |
7 |
Correct |
125 ms |
5224 KB |
Output is correct |
8 |
Correct |
130 ms |
5224 KB |
Output is correct |
9 |
Correct |
6 ms |
1920 KB |
Output is correct |
10 |
Correct |
7 ms |
1920 KB |
Output is correct |
11 |
Correct |
7 ms |
1920 KB |
Output is correct |
12 |
Correct |
13 ms |
2176 KB |
Output is correct |
13 |
Correct |
70 ms |
3696 KB |
Output is correct |
14 |
Correct |
122 ms |
5224 KB |
Output is correct |
15 |
Correct |
123 ms |
5228 KB |
Output is correct |
16 |
Correct |
121 ms |
5224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
1920 KB |
Output is correct |
2 |
Correct |
6 ms |
1920 KB |
Output is correct |
3 |
Correct |
6 ms |
1920 KB |
Output is correct |
4 |
Correct |
7 ms |
1920 KB |
Output is correct |
5 |
Correct |
14 ms |
2176 KB |
Output is correct |
6 |
Correct |
124 ms |
5224 KB |
Output is correct |
7 |
Correct |
125 ms |
5224 KB |
Output is correct |
8 |
Correct |
130 ms |
5224 KB |
Output is correct |
9 |
Correct |
6 ms |
1920 KB |
Output is correct |
10 |
Correct |
7 ms |
1920 KB |
Output is correct |
11 |
Correct |
7 ms |
1920 KB |
Output is correct |
12 |
Correct |
13 ms |
2176 KB |
Output is correct |
13 |
Correct |
70 ms |
3696 KB |
Output is correct |
14 |
Correct |
122 ms |
5224 KB |
Output is correct |
15 |
Correct |
123 ms |
5228 KB |
Output is correct |
16 |
Correct |
121 ms |
5224 KB |
Output is correct |
17 |
Correct |
6 ms |
1920 KB |
Output is correct |
18 |
Correct |
7 ms |
2044 KB |
Output is correct |
19 |
Correct |
16 ms |
2688 KB |
Output is correct |
20 |
Correct |
73 ms |
3824 KB |
Output is correct |
21 |
Correct |
101 ms |
4472 KB |
Output is correct |
22 |
Correct |
124 ms |
5224 KB |
Output is correct |
23 |
Correct |
123 ms |
5228 KB |
Output is correct |
24 |
Correct |
158 ms |
6500 KB |
Output is correct |
25 |
Correct |
250 ms |
11244 KB |
Output is correct |
26 |
Correct |
273 ms |
14436 KB |
Output is correct |