Submission #335125

#TimeUsernameProblemLanguageResultExecution timeMemory
335125blueDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms364 KiB
#include "molecules.h" #include <vector> #include <algorithm> using namespace std; vector<int> W; int n; vector<int> find_subset(int l, int u, vector<int> w) { W = w; n = w.size(); int i, x; vector<int> I(n); for(i = 0; i < n; i++) I[i] = i; sort(I.begin(), I.end(), [] (int x, int y) { return W[x] < W[y]; }); int sum = 0; vector<int> empty_res; vector<int> res; if(w[I[0]] > u) return empty_res; for(x = 0; x < n && sum < l; x++) { i = I[x]; sum += w[i]; res.push_back(i); } if(sum < l) return empty_res; res.pop_back(); res.push_back(I[n-1]); return res; }
#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...