Submission #150885

#TimeUsernameProblemLanguageResultExecution timeMemory
150885khsoo01Crosses on the Grid (FXCUP4_cross)C++17
100 / 100
113 ms7072 KiB
#include "cross.h" #include<bits/stdc++.h> #define X first #define Y second using namespace std; typedef pair<int,int> pii; typedef long long ll; long long SelectCross(int K, vector<int> I, vector<int> O) { vector<pii> V; int N = I.size(); for(int i=0;i<N;i++) { V.push_back({-I[i], O[i]}); } sort(V.begin(), V.end()); priority_queue<int> Q; ll ans = 0; for(int i=0;i<N;i++) { Q.push(-V[i].Y); if(Q.size() > K) Q.pop(); if(i >= K-1) ans = max(ans, -1ll*V[i].X*V[i].X +2ll*V[i].X*Q.top()); } return ans; }

Compilation message (stderr)

cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:21:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(Q.size() > K) Q.pop();
      ~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...