Submission #148006

#TimeUsernameProblemLanguageResultExecution timeMemory
148006imsifileCrosses on the Grid (FXCUP4_cross)C++17
100 / 100
122 ms12744 KiB
#include "cross.h" #include <algorithm> #include <queue> using namespace std; typedef long long lld; struct cross { lld in, ou; bool operator< (const cross& c) const { return ou > c.ou; } } ba[202020]; priority_queue<lld> pq; lld SelectCross(int K, vector<int> I, vector<int> O) { int N=I.size(); for(int i=0; i<N; i++) ba[i].in=I[i], ba[i].ou=O[i]; sort(ba, ba+N); lld mx=0; for(int i=0; i<N; i++){ pq.push(-ba[i].in); if(i>=K) pq.pop(); if(i>=K-1){ lld ii=-pq.top(), oo=ba[i].ou; if(mx < 2*ii*oo-ii*ii) mx = 2*ii*oo-ii*ii; } } return mx; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...