Submission #734435

#TimeUsernameProblemLanguageResultExecution timeMemory
734435rnl42Detecting Molecules (IOI16_molecules)C++14
10 / 100
1 ms304 KiB
#include "molecules.h" #include <algorithm> #include <iostream> #include <numeric> using namespace std; vector<int> find_subset(int l, int u, vector<int> _w) { const int N = _w.size(); vector<int> ids(N), w(N); iota(ids.begin(), ids.end(), 0); sort(ids.begin(), ids.end(), [&_w](const int a, const int b) { return _w[a] < _w[b]; }); for (int i = 0; i < N; i++) { w[i] = _w[ids[i]]; } vector<int> ans; long long sum = 0; for (int i = 0; i < N && sum + w[i] <= u; i++) { sum += w[i]; ans.push_back(ids[i]); } for (int i = 0; sum < l && i < (N - (int)ans.size()); i++) { sum -= w[i]; sum += w[N-1-i]; ans[i] = ids[N-1-i]; } if (sum < l) { ans.clear(); } 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...