Submission #148842

#TimeUsernameProblemLanguageResultExecution timeMemory
148842White Fairy (#200)Crosses on the Grid (FXCUP4_cross)C++17
100 / 100
124 ms6632 KiB
#include "cross.h" #include <bits/stdc++.h> using namespace std; long long SelectCross(int K, std::vector<int> I, std::vector<int> O) { int N = I.size(); vector<pair<int, int>> pairs(N); for (int i = 0; i < N; ++i) { pairs[i] = {I[i], O[i]}; } sort(pairs.begin(), pairs.end()); reverse(pairs.begin(), pairs.end()); priority_queue<int> pq; long long ans = 0; for (int i = 0; i < N; ++i) { pq.push(-pairs[i].second); while (pq.size() > K) { pq.pop(); } if (pq.size() == K) { int din = pairs[i].first, dout = -pq.top(); ans = max(ans, 1LL * dout * dout - 1LL * (dout - din) * (dout - din)); } } return ans; }

Compilation message (stderr)

cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:18:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while (pq.size() > K) {
            ~~~~~~~~~~^~~
cross.cpp:21:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (pq.size() == K) {
         ~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...