Submission #149998

#TimeUsernameProblemLanguageResultExecution timeMemory
149998GucciBelt (#200)Crosses on the Grid (FXCUP4_cross)C++17
0 / 100
6 ms384 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; 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(), greater<pii>()); priority_queue<int, vector<int>, greater<int> > Q; for(auto x : vec) { // cerr << x.x << ' ' << x.y << endl; Q.emplace(x.y); if(Q.size() == K+1) Q.pop(); if(Q.size() == K) { int v = min(x.y, Q.top()); ans = max(ans, 1ll * x.x * x.x - (x.x - v) * (x.x - v)); } } 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+1) Q.pop();
      ~~~~~~~~~^~~~~~
cross.cpp:22:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(Q.size() == K) {
      ~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...