Submission #764258

#TimeUsernameProblemLanguageResultExecution timeMemory
764258idkhandleCrosses on the Grid (FXCUP4_cross)C++17
63 / 100
1078 ms18240 KiB
#include "cross.h" #include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; using ll = long long; const int INF = 1e9; ll SelectCross(int K, vector<int> I, vector<int> O) { int n = I.size(); vector<pii> a; for (int i = 0; i < n; i++) { a.emplace_back(I[i], O[i]); } sort(a.begin(), a.end()); multiset<int> st; ll ans = 0; for (int i = n - 1; i >= 0; i--) { if (st.size() >= K - 1) { auto it = st.rbegin(); for (int j = 0; j < K - 2; j++) { it = next(it); } ans = max(ans, a[i].first * (2LL * min((K == 1 ? INF : *it), a[i].second) - a[i].first)); } st.insert(a[i].second); } return ans; }

Compilation message (stderr)

cross.cpp: In function 'll SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:21:17: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   21 |   if (st.size() >= K - 1) {
      |       ~~~~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...