This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |