# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
764272 | idkhandle | Crosses on the Grid (FXCUP4_cross) | C++17 | 106 ms | 18152 KiB |
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;
using pii = pair<int, int>;
using ll = long long;
const int INF = 1e9;
ll SelectCross(int K, vector<int> I, vector<int> O) {
int n = I.size();
vector<pii> a;
for (int i = 0; i < n; i++) {
a.emplace_back(I[i], O[i]);
}
sort(a.begin(), a.end());
multiset<int> st;
ll ans = 0;
for (int i = n - 1; i >= 0; i--) {
if (st.size() >= K - 1) {
ans = max(ans, a[i].first * (2LL * min((K == 1 ? INF : *st.begin()), a[i].second) - a[i].first));
st.insert(a[i].second);
st.erase(st.begin());
}
else {
st.insert(a[i].second);
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |