#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();
vector<pair<int, int>> v;
for(int i=0; i<N; i++) v.emplace_back(I[i], O[i]);
sort(v.rbegin(), v.rend());
//for(int i=0;i <N; i++) cout << v[i].first << ' '; cout << endl;
//for(int i=0;i <N; i++) cout << v[i].second << ' '; cout << endl;
priority_queue<int, vector<int>, greater<int>> s;
for(int i=0; i<K-1; i++) {
s.push(v[i].second);
}
long long res = 0;
for(int i=K-1; i<N; i++) {
int ii = v[i].first;
int oo = s.size() ? min(s.top(), v[i].second) : v[i].second;
// cout << oo << ' ' << ii << endl;
res = max(res, 1LL*oo*oo - 1LL*(oo-ii)*(oo-ii));
if((int)s.size() > K-1) s.pop();
s.push(v[i].second);
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Incorrect |
6 ms |
256 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Incorrect |
6 ms |
256 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Incorrect |
6 ms |
256 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |