Submission #150548

#TimeUsernameProblemLanguageResultExecution timeMemory
150548Ian and 2-bit memory (#200)Crosses on the Grid (FXCUP4_cross)C++17
100 / 100
124 ms6636 KiB
#include <bits/stdc++.h> using namespace std; #include "cross.h" long long SelectCross(int K, vector<int> I, vector<int> O) { int N = I.size(); vector<pair<int, int>> v(N); for (int i = 0; i < N; i++) v[i] = {O[i], I[i]}; sort(v.begin(), v.end(), greater<pair<int, int>>()); priority_queue<int, vector<int>, greater<int>> q; long long ans = 0; for (auto& i : v) { q.push(i.second); if (q.size() > K) q.pop(); if (q.size() == K) { long long ta = i.first; long long tb = ta - q.top(); ans = max(ans, ta * ta - tb * tb); } } return ans; }

Compilation message (stderr)

cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:17:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (q.size() > K)
       ~~~~~~~~~^~~
cross.cpp:19:16: 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...