#include "cross.h"
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;
ll SelectCross(int K, vector<int> I, vector<int> O) {
int N = I.size();
vector<pair<ll, ll>> crosses;
FOR(i, 0, N) crosses.push_back({I[i], O[i]});
sort(crosses.begin(), crosses.end(), greater<pair<ll, ll>>());
priority_queue<ll> pq;
ll ans = 0;
FOR(i, 0, N) {
pq.push(-crosses[i].second);
if (i >= K) pq.pop();
if (i >= K - 1) ans = max(ans, -pq.top() * crosses[i].first * 2 - crosses[i].first * crosses[i].first);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
252 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
9 ms |
888 KB |
Output is correct |
6 |
Correct |
105 ms |
7644 KB |
Output is correct |
7 |
Correct |
105 ms |
7648 KB |
Output is correct |
8 |
Correct |
110 ms |
7760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
252 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
9 ms |
888 KB |
Output is correct |
6 |
Correct |
105 ms |
7644 KB |
Output is correct |
7 |
Correct |
105 ms |
7648 KB |
Output is correct |
8 |
Correct |
110 ms |
7760 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Correct |
3 ms |
376 KB |
Output is correct |
12 |
Correct |
8 ms |
1148 KB |
Output is correct |
13 |
Correct |
57 ms |
6116 KB |
Output is correct |
14 |
Correct |
114 ms |
11500 KB |
Output is correct |
15 |
Correct |
110 ms |
11632 KB |
Output is correct |
16 |
Correct |
109 ms |
11484 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
252 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
9 ms |
888 KB |
Output is correct |
6 |
Correct |
105 ms |
7644 KB |
Output is correct |
7 |
Correct |
105 ms |
7648 KB |
Output is correct |
8 |
Correct |
110 ms |
7760 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
256 KB |
Output is correct |
11 |
Correct |
3 ms |
376 KB |
Output is correct |
12 |
Correct |
8 ms |
1148 KB |
Output is correct |
13 |
Correct |
57 ms |
6116 KB |
Output is correct |
14 |
Correct |
114 ms |
11500 KB |
Output is correct |
15 |
Correct |
110 ms |
11632 KB |
Output is correct |
16 |
Correct |
109 ms |
11484 KB |
Output is correct |
17 |
Correct |
2 ms |
376 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
9 ms |
1268 KB |
Output is correct |
20 |
Correct |
60 ms |
6024 KB |
Output is correct |
21 |
Correct |
89 ms |
10080 KB |
Output is correct |
22 |
Correct |
113 ms |
11632 KB |
Output is correct |
23 |
Correct |
117 ms |
11528 KB |
Output is correct |
24 |
Correct |
119 ms |
11480 KB |
Output is correct |
25 |
Correct |
122 ms |
13652 KB |
Output is correct |
26 |
Correct |
112 ms |
14196 KB |
Output is correct |