Submission #150878

#TimeUsernameProblemLanguageResultExecution timeMemory
150878gs14004Crosses on the Grid (FXCUP4_cross)C++17
100 / 100
118 ms10724 KiB
#include "cross.h" #include <bits/stdc++.h> #define sz(v) ((int)(v).size()) using namespace std; using pi = pair<int, int>; using lint = long long; const int MAXN = 200005; int N; lint X[MAXN], Y[MAXN]; lint func(lint X, lint Y){ return 2 * X * Y - X * X; } long long SelectCross(int K, std::vector<int> I, std::vector<int> O) { N = I.size(); vector<pi> v, A; for(int i=0; i<N; i++) v.emplace_back(I[i], O[i]); sort(v.begin(), v.end()); reverse(v.begin(), v.end()); priority_queue<int, vector<int>, greater<int> > pq; lint ret = 0; for(int i=0; i<sz(v); ){ int e = i; while(e < sz(v) && v[i].first == v[e].first) e++; for(int j=i; j<e; j++) pq.push(v[j].second); while(sz(pq) > K) pq.pop(); if(sz(pq) == K) ret = max(ret, func(v[i].first, pq.top())); i = e; } return ret; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...