Submission #151339

#TimeUsernameProblemLanguageResultExecution timeMemory
151339dongwon0427Crosses on the Grid (FXCUP4_cross)C++17
100 / 100
113 ms10728 KiB
#include "cross.h" #include <bits/stdc++.h> using namespace std; typedef pair<int,int> pii; typedef long long ll; long long SelectCross(int k, std::vector<int> I, std::vector<int> O) { int n = I.size(); vector<pii> v; for(int i=0;i<n;i++) { v.push_back(pii(O[i], I[i])); } sort(v.begin(), v.end()); priority_queue<int> pq; for(int i=n-k;i<n;i++) { pq.push(-v[i].second); } ll ret = (ll)v[n-k].first * v[n-k].first - (ll)(v[n-k].first + pq.top()) * (v[n-k].first + pq.top()); for(int i=n-k-1;i>=0;i--) { if(-v[i].second <= pq.top()) { pq.pop(); pq.push(-v[i].second); } ret = max(ret, (ll)v[i].first * v[i].first - (ll)(v[i].first + pq.top()) * (v[i].first + pq.top())); } return ret; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...