Submission #113019

#TimeUsernameProblemLanguageResultExecution timeMemory
113019imsifileCrosses on the Grid (FXCUP4_cross)C++17
100 / 100
93 ms8812 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 N, int K, vector<int> I, vector<int> O) { 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...