Submission #150591

#TimeUsernameProblemLanguageResultExecution timeMemory
150591usa1+samsung2 (#200)Crosses on the Grid (FXCUP4_cross)C++17
8 / 100
113 ms6764 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...