Submission #151138

#TimeUsernameProblemLanguageResultExecution timeMemory
151138kuroniCrosses on the Grid (FXCUP4_cross)C++17
100 / 100
116 ms10724 KiB
#include "cross.h" #include <bits/stdc++.h> using namespace std; long long SelectCross(int k, vector<int> s, vector<int> l) { vector<pair<int, int>> ve; int n = s.size(); long long ans = 0; for (int i = 0; i < n; i++) ve.push_back({s[i], l[i]}); sort(ve.begin(), ve.end(), greater<pair<int, int>>()); priority_queue<int, vector<int>, greater<int>> pq; for (int i = 0; i < n; i++) { pq.push(ve[i].second); if (pq.size() > k) pq.pop(); if (pq.size() == k) ans = max(ans, 1LL * ve[i].first * ve[i].first + 2LL * (pq.top() - ve[i].first) * ve[i].first); } return ans; }

Compilation message (stderr)

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