Submission #881831

#TimeUsernameProblemLanguageResultExecution timeMemory
881831theghostkingDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms432 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { long long n = w.size(); vector<pair<long long,long long>> vec(n); for (long long i = 0; i<n; i++){ vec[i] = {w[i],i}; } sort(vec.begin(),vec.end()); vector<bool> vis(n); long long pt = n-1; long long cr = 0; while (pt >= 0){ if (cr < l){ cr += vec[pt].first; vis[pt] = true; pt--; } if (pt < 0) break; if ((l <= cr) && (cr <= u)){ break; } if (cr > u){ cr -= vec[n-1].first; cr += vec[0].first; vis[n-1] = false; vis[0] = true; break; } } vector<int> ans; if (cr < l || cr > u){ return ans; } else{ for (long long i = 0; i<n; i++){ if (vis[i]) ans.push_back(i); } return ans; } }
#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...