Submission #739558

#TimeUsernameProblemLanguageResultExecution timeMemory
739558Abrar_Al_SamitDetecting Molecules (IOI16_molecules)C++17
100 / 100
44 ms5940 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); vector<int>id(n); iota(id.begin(), id.end(), 0); sort(id.begin(), id.end(), [&] (int i, int j) { return w[i] < w[j]; }); if(w[id[0]]>u) return vector<int>(0); vector<int>ret; long long cur = 0; int j = -1; for(int i=0; i<n; ++i) { ret.push_back(id[i]); cur += w[id[i]]; if(cur>=l) { if(cur>u) { ret.pop_back(); cur -= w[id[i]]; j = i; break; } else { return ret; } } } if(j==-1) return vector<int>(0); int at = 0; while(j<n && cur<l) { ret.push_back(id[j]); cur += w[id[j]]; ++j; cur -= w[ret[at]]; ++at; } if(cur<l) ret.clear(); else ret = vector<int>(ret.begin()+at, ret.end()); return ret; }
#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...