Submission #431085

#TimeUsernameProblemLanguageResultExecution timeMemory
431085davi_bartDetecting Molecules (IOI16_molecules)C++17
100 / 100
59 ms6796 KiB
#include "molecules.h" #pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define ld long double #define pb push_back std::vector<int> find_subset(int l, int u, std::vector<int> p) { vector<pair<ll,ll> > w; for(ll i=0;i<p.size();i++)w.pb({p[i],i}); vector<int> ans; ll tot=0; sort(w.begin(),w.end()); reverse(w.begin(),w.end()); for(ll i=0;i<w.size();i++){ ans.pb(w[i].se); tot+=w[i].fi; if(tot>=l)break; } if(tot>=l && tot<=u)return ans; ll pos=0; for(ll i=w.size()-1;i>=ans.size();i--){ tot-=p[ans[pos]]; ans[pos]=w[i].se; tot+=p[ans[pos]]; pos++; if(pos>=ans.size())break; if(tot<=u)break; } if(tot>=l && tot<=u)return ans; ans.clear(); return ans; /*tot=0; sort(w.begin(),w.end()); for(int i=0;i<w.size();i++){ ans.pb(i); tot+=w[i]; if(tot>=l)break; } if(tot>=l && tot<=u)return ans; tot-=w[ans.back()]; ans.pop_back(); pos=0; for(int i=w.size()-1;i>=ans.size();i++){ tot-=w[ans[pos]]; ans[pos]=i; tot+=w[ans[pos]]; pos++; if(pos>=ans.size())break; if(tot>=l && tot<=u)break; } if(tot>=l && tot<=u)return ans; ans.clear(); return ans;*/ }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:12:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for(ll i=0;i<p.size();i++)w.pb({p[i],i});
      |                ~^~~~~~~~~
molecules.cpp:17:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(ll i=0;i<w.size();i++){
      |                ~^~~~~~~~~
molecules.cpp:25:26: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for(ll i=w.size()-1;i>=ans.size();i--){
      |                         ~^~~~~~~~~~~~
molecules.cpp:30:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         if(pos>=ans.size())break;
      |            ~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...