Submission #151233

#TimeUsernameProblemLanguageResultExecution timeMemory
151233dolphingarlicCrosses on the Grid (FXCUP4_cross)C++17
8 / 100
106 ms8036 KiB
#include "cross.h" #include <bits/stdc++.h> #define FOR(i, x, y) for (int i = x; i < y; i++) typedef long long ll; using namespace std; ll SelectCross(int K, vector<int> I, vector<int> O) { int N = I.size(); vector<pair<ll, ll>> crosses; FOR(i, 0, N) crosses.push_back({I[i], O[i]}); sort(crosses.begin(), crosses.end(), greater<pair<ll, ll>>()); priority_queue<ll> pq; ll ans = 0; FOR(i, 0, N) { pq.push(-crosses[i].second); if (pq.size() >= K) pq.pop(); if (pq.size() >= K - 1) ans = max(ans, -pq.top() * crosses[i].first * 2 - crosses[i].first * crosses[i].first); } return ans; }

Compilation message (stderr)

cross.cpp: In function 'll 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) pq.pop();
       ~~~~~~~~~~^~~~
cross.cpp:18:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (pq.size() >= K - 1) ans = max(ans, -pq.top() * crosses[i].first * 2 - crosses[i].first * crosses[i].first);
       ~~~~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...