Submission #113616

#TimeUsernameProblemLanguageResultExecution timeMemory
113616imsifileCrosses on the Grid (FXCUP4_cross)C++17
63 / 100
1072 ms6760 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]; lld ent[202020], cnt; 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; cnt=0; for(int i=0; i<N; i++){ ent[cnt++]=-ba[i].in; sort(ent, ent+cnt); if(i>=K) cnt--; if(i>=K-1){ lld ii=-ent[cnt-1], 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...