#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 |
1 |
Correct |
6 ms |
376 KB |
Output is correct |
2 |
Correct |
7 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
11 ms |
768 KB |
Output is correct |
6 |
Correct |
108 ms |
6760 KB |
Output is correct |
7 |
Correct |
113 ms |
6760 KB |
Output is correct |
8 |
Correct |
113 ms |
6764 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
376 KB |
Output is correct |
2 |
Correct |
7 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
11 ms |
768 KB |
Output is correct |
6 |
Correct |
108 ms |
6760 KB |
Output is correct |
7 |
Correct |
113 ms |
6760 KB |
Output is correct |
8 |
Correct |
113 ms |
6764 KB |
Output is correct |
9 |
Correct |
5 ms |
344 KB |
Output is correct |
10 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
376 KB |
Output is correct |
2 |
Correct |
7 ms |
384 KB |
Output is correct |
3 |
Correct |
6 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
11 ms |
768 KB |
Output is correct |
6 |
Correct |
108 ms |
6760 KB |
Output is correct |
7 |
Correct |
113 ms |
6760 KB |
Output is correct |
8 |
Correct |
113 ms |
6764 KB |
Output is correct |
9 |
Correct |
5 ms |
344 KB |
Output is correct |
10 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
11 |
Halted |
0 ms |
0 KB |
- |