Submission #149184

#TimeUsernameProblemLanguageResultExecution timeMemory
149184Little Piplup (#200)Crosses on the Grid (FXCUP4_cross)C++17
100 / 100
127 ms8808 KiB
#include "cross.h" #include<bits/stdc++.h> //using namespace std; long long SelectCross(int K, std::vector<int> I, std::vector<int> O) { int N = I.size(); std::pair<long long, long long> soo[N]; for ( int i = 0 ; i < N ; ++i ) { soo[i] = {O[i], I[i]}; } sort(soo, soo + N, std::greater< std::pair<long long, long long> >()); std::priority_queue<long long, std::vector<long long>, std::greater<long long>> puts; for ( int i = 0 ; i < K ; ++i ) { puts.push(soo[i].second); } long long out = soo[K-1].first; long long in = puts.top(); long long ret = out * out - (out-in) * (out-in); for ( int i = K ; i < N ; ++i ) { out = soo[i].first; puts.pop(); puts.push(soo[i].second); in = puts.top(); ret = std::max(ret, out * out - (out-in) * (out-in) ); } return ret; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...