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;
long long SelectCross(int k, std::vector<int> a, std::vector<int> b) {
int n = (int)a.size();
pair<int, int> c[200005] = {};
for (int i = 0; i < n; i++) c[i] = {b[i], a[i]};
sort(c, c + n); reverse(c, c + n);
multiset<int> s;
for (int i = 0; i < k; i++) s.insert(c[i].second);
long long z = 1ll * c[k - 1].first * c[k - 1].first - 1ll * *s.rbegin() * *s.rbegin();
for (int i = k; i < n; i++) {
s.insert(c[i].second);
s.erase(s.find(*s.rbegin()));
z = max(z, 1ll * c[i].first * c[i].first - 1ll * *s.rbegin() * *s.rbegin());
}
return z;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |