Submission #149593

#TimeUsernameProblemLanguageResultExecution timeMemory
149593Cafe Maru (#200)Crosses on the Grid (FXCUP4_cross)C++17
0 / 100
5 ms384 KiB
#include "cross.h" #include<bits/stdc++.h> using namespace std; map<int,vector<int>> oi; long long SelectCross(int K, std::vector<int> I, std::vector<int> O) { int N = I.size(); for(int i=0;i<N;i++) { oi[-O[i]].push_back(I[i]); } int ans = 0; priority_queue<int> pq; for(auto& [z, s] : oi) { int x = -z; for(int i : s) { pq.push(-i); } while(pq.size() > K) pq.pop(); if (pq.size() == K) { int y = -pq.top(); int tmp = y*(2*x-y); if(tmp > ans) ans = tmp; } } return ans; }

Compilation message (stderr)

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