Submission #68893

#TimeUsernameProblemLanguageResultExecution timeMemory
68893mr_bananaDetecting Molecules (IOI16_molecules)C++17
100 / 100
131 ms29980 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { vector<pair<int,int> > v; for(int i=0;i<w.size();i++){ v.push_back({w[i],i}); } set<pair<int,int> > ans; sort(v.begin(),v.end()); long long sum=0; for(int i=0;i<v.size();i++){ if(sum+v[i].first<=u){ sum+=v[i].first; ans.insert(v[i]); } else if(sum+v[i].first-ans.begin()->first<=u){ sum+=v[i].first-ans.begin()->first; ans.erase(ans.begin()); ans.insert(v[i]); } } vector<int> ans1; if(sum>=l){ for(auto i:ans){ ans1.push_back(i.second); } } return ans1; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:6:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<w.size();i++){
                 ~^~~~~~~~~
molecules.cpp:12:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<v.size();i++){
                 ~^~~~~~~~~
#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...