#include "cross.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
long long SelectCross(int k, std::vector<int> I, std::vector<int> O) {
int n = I.size();
vector<pii> v;
for(int i=0;i<n;i++) {
v.push_back(pii(I[i], O[i]));
}
sort(v.begin(), v.end());
vector<pii> w;
for(int i=0;i<n;i++) {
while(!w.empty() && w.back().second <= v[i].second) w.pop_back();
w.push_back(v[i]);
}
n = w.size();
k = min(k, n);
ll ret = 0;
for(int i=0;i+k-1<n;i++) {
ret = max(ret, (ll)w[i].first * w[i+k-1].second);
}
return ret;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |