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>
#define II i.o*i.o - (i.o - i.i)*(i.o - i.i)
#define JJ j.o*j.o - (j.o - j.i)*(j.o - j.i)
struct list {
long long i, o;
bool operator()(list i, list j) {
if (II > JJ) return true;
else if (II == JJ) return i.o < j.o;
return false;
}
}d[1000001];
long long SelectCross(int K, std::vector<int> I, std::vector<int> O) {
int N = I.size();
for (int i = 0; i < N; i++)
d[i].i = I[i], d[i].o = O[i];
std::sort(d, d + N, list());
long long l1 = d[0].o, l2 = d[0].i;
for (int i = 1; i < K; i++) {
if (l1 > d[i].o) l1 = d[i].o;
if (l2 > d[i].i) l2 = d[i].i;
}
long long ans = l1 * l1 - (l1 - l2) * (l1 - l2);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |