Submission #149467

#TimeUsernameProblemLanguageResultExecution timeMemory
149467Solo Leveling (#200)Crosses on the Grid (FXCUP4_cross)C++17
0 / 100
6 ms384 KiB
#include "cross.h" #include <bits/stdc++.h> using namespace std; #define pii pair<long long,long long> #define F first #define S second #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <bits/stdc++.h> using namespace __gnu_pbds; using namespace std; typedef long long ll; // order_of_key typedef tree< pair<int, int>, null_type, less<pair<ll, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; ordered_set X; long long SelectCross(int K, std::vector<int> I, std::vector<int> O) { vector<pii> v(I.size()); for(int i = 0 ; i < I.size() ; i ++){ v.push_back(pii(O[i] , I[i])); } sort(v.rbegin() , v.rend()); ll ans = 0; for(int i = 0 ; i < I.size() ; i ++){ X.insert(pii(-v[i].second, i)); if(X.size() >= K){ pii R = *X.find_by_order(K-1); R.first *= -1; R.first = min(R.first , v[i].second); // cout<<v[i].first * v[i].first<<" " << -2*(v[i].first - R.first) << endl; ans = max(ans ,v[i].first * v[i].first - 2LL*(v[i].first - R.first)); } // cout<<v[i].first<<" "<<v[i].second<<endl; } return ans; }

Compilation message (stderr)

cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:25:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0 ; i < I.size() ; i ++){
                  ~~^~~~~~~~~~
cross.cpp:30:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0 ; i < I.size() ; i ++){
                  ~~^~~~~~~~~~
cross.cpp:32:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(X.size() >= K){
      ~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...