#include "cross.h"
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
#define INF 1234567890
#define ll long long
ll res = 0;
vector<pair<int, int> > v;
priority_queue<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++)
v.push_back({ I[i], O[i] });
sort(v.rbegin(), v.rend());
int in_min = INF;
for (int i = 0; i < K; i++)
{
pq.push(-v[i].second);
in_min = min(in_min, v[i].first);
}
res = max(res, 2LL * -pq.top()*in_min - (ll)in_min*in_min);
for (int i = K; i < N; i++)
{
pq.push(-v[i].second);
in_min = min(in_min, v[i].first);
pq.pop();
res = max(res, 2LL * -pq.top()*in_min - (ll)in_min*in_min);
}
return res;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
128 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
11 ms |
768 KB |
Output is correct |
6 |
Correct |
108 ms |
5612 KB |
Output is correct |
7 |
Correct |
111 ms |
5476 KB |
Output is correct |
8 |
Correct |
106 ms |
5740 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
128 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
11 ms |
768 KB |
Output is correct |
6 |
Correct |
108 ms |
5612 KB |
Output is correct |
7 |
Correct |
111 ms |
5476 KB |
Output is correct |
8 |
Correct |
106 ms |
5740 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
6 ms |
384 KB |
Output is correct |
12 |
Correct |
11 ms |
768 KB |
Output is correct |
13 |
Correct |
67 ms |
3184 KB |
Output is correct |
14 |
Correct |
106 ms |
5740 KB |
Output is correct |
15 |
Correct |
112 ms |
5732 KB |
Output is correct |
16 |
Correct |
112 ms |
5736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
6 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
128 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
11 ms |
768 KB |
Output is correct |
6 |
Correct |
108 ms |
5612 KB |
Output is correct |
7 |
Correct |
111 ms |
5476 KB |
Output is correct |
8 |
Correct |
106 ms |
5740 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
5 ms |
376 KB |
Output is correct |
11 |
Correct |
6 ms |
384 KB |
Output is correct |
12 |
Correct |
11 ms |
768 KB |
Output is correct |
13 |
Correct |
67 ms |
3184 KB |
Output is correct |
14 |
Correct |
106 ms |
5740 KB |
Output is correct |
15 |
Correct |
112 ms |
5732 KB |
Output is correct |
16 |
Correct |
112 ms |
5736 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
6 ms |
384 KB |
Output is correct |
19 |
Correct |
11 ms |
768 KB |
Output is correct |
20 |
Correct |
62 ms |
3180 KB |
Output is correct |
21 |
Correct |
88 ms |
5096 KB |
Output is correct |
22 |
Correct |
110 ms |
5736 KB |
Output is correct |
23 |
Correct |
127 ms |
5740 KB |
Output is correct |
24 |
Correct |
119 ms |
5740 KB |
Output is correct |
25 |
Correct |
119 ms |
6464 KB |
Output is correct |
26 |
Correct |
116 ms |
6884 KB |
Output is correct |