#include "cross.h"
#include <algorithm>
#include <utility>
#include <set>
std::vector<std::pair<int, int> > p;
std::multiset<int> st;
long long SelectCross(int K, std::vector<int> I, std::vector<int> O) {
int N = I.size();
for (int i = 0; i < N; i++)
p.push_back(std::make_pair(O[i], I[i]));
std::sort(p.begin(), p.end()); std::reverse(p.begin(), p.end());
for (int i = 0; i < K - 1; i++)
st.insert(p[i].second);
st.insert(2000000000);
auto si = st.begin();
long long ans = 0;
for (int i = K - 1; i < N; i++) {
int t = p[i].first - std::min((*si), p[i].second);
ans = std::max(ans, 1LL * p[i].first * p[i].first - 1LL * t * t);
if (p[i].second >(*si)) {
st.insert(p[i].second); ++si;
}
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
128 KB |
Output is correct |
2 |
Correct |
5 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 |
12 ms |
768 KB |
Output is correct |
6 |
Correct |
118 ms |
5736 KB |
Output is correct |
7 |
Correct |
118 ms |
5740 KB |
Output is correct |
8 |
Correct |
137 ms |
5608 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
128 KB |
Output is correct |
2 |
Correct |
5 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 |
12 ms |
768 KB |
Output is correct |
6 |
Correct |
118 ms |
5736 KB |
Output is correct |
7 |
Correct |
118 ms |
5740 KB |
Output is correct |
8 |
Correct |
137 ms |
5608 KB |
Output is correct |
9 |
Correct |
6 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 |
12 ms |
640 KB |
Output is correct |
13 |
Correct |
64 ms |
3184 KB |
Output is correct |
14 |
Correct |
119 ms |
5732 KB |
Output is correct |
15 |
Correct |
120 ms |
5736 KB |
Output is correct |
16 |
Correct |
117 ms |
5736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
128 KB |
Output is correct |
2 |
Correct |
5 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 |
12 ms |
768 KB |
Output is correct |
6 |
Correct |
118 ms |
5736 KB |
Output is correct |
7 |
Correct |
118 ms |
5740 KB |
Output is correct |
8 |
Correct |
137 ms |
5608 KB |
Output is correct |
9 |
Correct |
6 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 |
12 ms |
640 KB |
Output is correct |
13 |
Correct |
64 ms |
3184 KB |
Output is correct |
14 |
Correct |
119 ms |
5732 KB |
Output is correct |
15 |
Correct |
120 ms |
5736 KB |
Output is correct |
16 |
Correct |
117 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 |
15 ms |
1152 KB |
Output is correct |
20 |
Correct |
68 ms |
3944 KB |
Output is correct |
21 |
Correct |
95 ms |
5096 KB |
Output is correct |
22 |
Correct |
115 ms |
5740 KB |
Output is correct |
23 |
Correct |
118 ms |
5740 KB |
Output is correct |
24 |
Correct |
139 ms |
8168 KB |
Output is correct |
25 |
Correct |
219 ms |
13148 KB |
Output is correct |
26 |
Correct |
235 ms |
14436 KB |
Output is correct |