Submission #148503

#TimeUsernameProblemLanguageResultExecution timeMemory
148503강력한 한방 필살기 (#200)Crosses on the Grid (FXCUP4_cross)C++17
100 / 100
121 ms6876 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...