Submission #148942

#TimeUsernameProblemLanguageResultExecution timeMemory
148942JeffreyHo (#200)Crosses on the Grid (FXCUP4_cross)C++17
0 / 100
7 ms1968 KiB
#include "cross.h" #include <bits/stdc++.h> using namespace std; long long SelectCross(int k, std::vector<int> a, std::vector<int> b) { int n = (int)a.size(); pair<int, int> c[200005] = {}; for (int i = 0; i < n; i++) c[i] = {b[i], a[i]}; sort(c, c + n); reverse(c, c + n); multiset<int> s; for (int i = 0; i < k; i++) s.insert(c[i].second); long long z = 1ll * c[k - 1].first * c[k - 1].first - 1ll * *s.rbegin() * *s.rbegin(); for (int i = k; i < n; i++) { s.insert(c[i].second); s.erase(s.find(*s.rbegin())); z = max(z, 1ll * c[i].first * c[i].first - 1ll * *s.rbegin() * *s.rbegin()); } return z; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...