#include "cross.h"
#include<bits/stdc++.h>
//using namespace std;
long long SelectCross(int K, std::vector<int> I, std::vector<int> O) {
int N = I.size();
std::pair<long long, long long> soo[N];
for ( int i = 0 ; i < N ; ++i ) {
soo[i] = {O[i], I[i]};
}
sort(soo, soo + N, std::greater< std::pair<long long, long long> >());
std::priority_queue<long long, std::vector<long long>, std::greater<long long>> puts;
for ( int i = 0 ; i < K ; ++i ) {
puts.push(soo[i].second);
}
long long out = soo[K-1].first;
long long in = puts.top();
long long ret = out * out - (out-in) * (out-in);
for ( int i = K ; i < N ; ++i ) {
out = soo[i].first;
puts.pop();
puts.push(soo[i].second);
in = puts.top();
ret = std::max(ret, out * out - (out-in) * (out-in) );
}
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
6 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 |
768 KB |
Output is correct |
6 |
Correct |
112 ms |
6760 KB |
Output is correct |
7 |
Correct |
121 ms |
6764 KB |
Output is correct |
8 |
Correct |
115 ms |
6628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
6 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 |
768 KB |
Output is correct |
6 |
Correct |
112 ms |
6760 KB |
Output is correct |
7 |
Correct |
121 ms |
6764 KB |
Output is correct |
8 |
Correct |
115 ms |
6628 KB |
Output is correct |
9 |
Correct |
6 ms |
384 KB |
Output is correct |
10 |
Correct |
6 ms |
384 KB |
Output is correct |
11 |
Correct |
7 ms |
384 KB |
Output is correct |
12 |
Correct |
13 ms |
768 KB |
Output is correct |
13 |
Correct |
62 ms |
3696 KB |
Output is correct |
14 |
Correct |
120 ms |
6760 KB |
Output is correct |
15 |
Correct |
115 ms |
6640 KB |
Output is correct |
16 |
Correct |
120 ms |
6760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
384 KB |
Output is correct |
2 |
Correct |
6 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 |
768 KB |
Output is correct |
6 |
Correct |
112 ms |
6760 KB |
Output is correct |
7 |
Correct |
121 ms |
6764 KB |
Output is correct |
8 |
Correct |
115 ms |
6628 KB |
Output is correct |
9 |
Correct |
6 ms |
384 KB |
Output is correct |
10 |
Correct |
6 ms |
384 KB |
Output is correct |
11 |
Correct |
7 ms |
384 KB |
Output is correct |
12 |
Correct |
13 ms |
768 KB |
Output is correct |
13 |
Correct |
62 ms |
3696 KB |
Output is correct |
14 |
Correct |
120 ms |
6760 KB |
Output is correct |
15 |
Correct |
115 ms |
6640 KB |
Output is correct |
16 |
Correct |
120 ms |
6760 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 |
1024 KB |
Output is correct |
20 |
Correct |
67 ms |
3700 KB |
Output is correct |
21 |
Correct |
98 ms |
5484 KB |
Output is correct |
22 |
Correct |
125 ms |
6764 KB |
Output is correct |
23 |
Correct |
127 ms |
6760 KB |
Output is correct |
24 |
Correct |
126 ms |
7148 KB |
Output is correct |
25 |
Correct |
127 ms |
8804 KB |
Output is correct |
26 |
Correct |
119 ms |
8808 KB |
Output is correct |