# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
150202 | usa1+samsung2 (#200) | Crosses on the Grid (FXCUP4_cross) | C++17 | 6 ms | 384 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 <algorithm>
long long SelectCross(int K, std::vector<int> I, std::vector<int> O) {
std::vector<std::pair<int, int>> v1(I.size());
std::vector<std::pair<int, int>> v2(I.size());
int N = I.size();
for (int i = 0; i < I.size(); i++) {
v1[i].first = I[i];
v1[i].second = O[i];
}
for (int i = 0; i < I.size(); i++) {
v2[i].first = O[i];
v2[i].second = I[i];
}
std::sort(v1.rbegin(), v1.rend());
std::sort(v2.rbegin(), v2.rend());
long long l1 = v1[0].first, l2 = v1[0].second;
for (int i = 1; i < K; i++) {
if (l1 > v1[i].first) l1 = v1[i].first;
if (l2 > v1[i].second) l2 = v1[i].second;
}
long long ans = l2 * l2 - (l2 - l1)*(l2 - l1);
l1 = v1[0].first, l2 = v1[0].second;
for (int i = 1; i < K; i++) {
if (l1 > v1[i].first) l1 = v1[i].first;
if (l2 > v1[i].second) l2 = v1[i].second;
}
if (ans < l1 * l1 - (l1 - l2)*(l1 - l2))
ans = l1 * l1 - (l1 - l2)*(l1 - l2);
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... |