# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
151138 | kuroni | Crosses on the Grid (FXCUP4_cross) | C++17 | 116 ms | 10724 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;
long long SelectCross(int k, vector<int> s, vector<int> l)
{
vector<pair<int, int>> ve;
int n = s.size();
long long ans = 0;
for (int i = 0; i < n; i++)
ve.push_back({s[i], l[i]});
sort(ve.begin(), ve.end(), greater<pair<int, int>>());
priority_queue<int, vector<int>, greater<int>> pq;
for (int i = 0; i < n; i++)
{
pq.push(ve[i].second);
if (pq.size() > k)
pq.pop();
if (pq.size() == k)
ans = max(ans, 1LL * ve[i].first * ve[i].first + 2LL * (pq.top() - ve[i].first) * ve[i].first);
}
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... |