Submission #149438

#TimeUsernameProblemLanguageResultExecution timeMemory
149438Solo Leveling (#200)Crosses on the Grid (FXCUP4_cross)C++17
0 / 100
5 ms384 KiB
#include "cross.h" #include <bits/stdc++.h> using namespace std; #define pii pair<int,int> #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; // order_of_key typedef tree< pair<int, int>, null_type, less<pair<int, 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) { #define int long long 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()); long long ans = 0; for(int i = 0 ; i < I.size() ; i ++){ if(X.size() >= K - 1){ pii R = *X.find_by_order(K-2); 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 - 2*(v[i].first - R.first)); } // cout<<v[i].first<<" "<<v[i].second<<endl; X.insert(pii(-v[i].second, i)); } #undef int 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:31:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(X.size() >= K - 1){
      ~~~~~~~~~^~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...