Submission #413941

#TimeUsernameProblemLanguageResultExecution timeMemory
413941DaktoDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms204 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<pair<int,int>> v; for(int i=0; i<w.size(); i++){ v.push_back({w[i],i}); } sort(v.begin(),v.end()); auto f=v[0]; v.erase(v.begin()); vector<int> res; int s=0; while(!v.empty() && s<l){ if(s+f.first>=l){ s+=f.first; res.push_back(f.second); break; } s+=end(v)->first; res.push_back(v.back().second); v.erase(v.end()-1); if(s>=l) break; if(s+f.first>=l){ s+=f.first; res.push_back(f.second); break; } } if(s>=l && s<=u) return res; else return vector<int>(0); }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for(int i=0; i<w.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...