Submission #209097

#TimeUsernameProblemLanguageResultExecution timeMemory
209097my99nDetecting Molecules (IOI16_molecules)C++14
9 / 100
6 ms380 KiB
#include<bits/stdc++.h> using namespace std; #include "molecules.h" vector<int> find_subset(int l, int u, vector<int> w) { vector<int> ans; vector<pair<int,int>> s; for (int i = 0; i < w.size(); i++) s.push_back({w[i], i}); sort(s.begin(), s.end()); int wmax = (s.end()-1)->first, wmin = s.begin()->first; if (wmin > u) return vector<int>(0); if (l <= wmin and u >= wmin) return vector<int>(1, 0); if (l <= wmax and u >= wmax) return vector<int>(1, s.size()-1); reverse(s.begin(), s.end()); int val = 0; for (int i = 0; i < s.size(); i++) { ans.push_back(s.size()-s[i].second-1); val += s[i].first; if (val < l) continue; if (l <= val and val <= u) return ans; if (u < val) { ans.pop_back(); val -= w[i]; continue; } } return vector<int>(0); }

Compilation message (stderr)

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