Submission #149139

#TimeUsernameProblemLanguageResultExecution timeMemory
149139ummm (#200)Crosses on the Grid (FXCUP4_cross)C++17
100 / 100
141 ms8812 KiB
/* cerberus97 - Hanit Banga */ #include "cross.h" #include <iostream> #include <iomanip> #include <cassert> #include <cmath> #include <cstdio> #include <cstring> #include <cstdlib> #include <map> #include <set> #include <queue> #include <stack> #include <vector> #include <algorithm> using namespace std; #define pb push_back #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL) typedef long long ll; typedef long double ld; typedef pair <int, int> pii; typedef pair <ll, ll> pll; const ll inf = 1e18 + 42; ll SelectCross(int K, std::vector<int> I, std::vector<int> O) { int N = I.size(); vector<pll> C(N); for (int i = 0; i < N; ++i) { C[i] = {I[i], O[i]}; } sort(C.begin(), C.end(), greater<pll>()); priority_queue<ll, vector<ll>, greater<ll>> q; ll best = 0; for (int i = 0; i < N; ++i) { q.push(C[i].second); if (q.size() > K) { q.pop(); } if (i >= K - 1) { best = max(best, C[i].first * (2 * q.top() - C[i].first)); } } return best; }

Compilation message (stderr)

cross.cpp: In function 'll SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:41: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...