Submission #150073

#TimeUsernameProblemLanguageResultExecution timeMemory
150073GucciBelt (#200)Crosses on the Grid (FXCUP4_cross)C++17
100 / 100
128 ms6760 KiB
#include <bits/stdc++.h> #include "cross.h" #define long long long #define pii pair<int, int> #define x first #define y second using namespace std; const int INF = 1e9+1; int n; long ans; long SelectCross(int K, vector<int> I, vector<int> O) { n = I.size(); vector<pii> vec; for(int i = 0; i < n; ++i) vec.emplace_back(O[i], I[i]); sort(vec.begin(), vec.end(), [&](const pii &a, const pii &b) { if(a.x != b.x) return a.x > b.x; return a.y < b.y; }); priority_queue<int, vector<int>, greater<int> > Q; for(auto x : vec) { // cerr << x.x << ' ' << x.y << endl; if(Q.size() == K) Q.pop(); if(Q.size() == K-1) { int v = min(x.y, Q.empty() ? INF : Q.top()); ans = max(ans, 1ll * x.x * x.x - 1ll * (x.x - v) * (x.x - v)); } Q.emplace(x.y); } return ans; }

Compilation message (stderr)

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