Submission #404058

#TimeUsernameProblemLanguageResultExecution timeMemory
404058luisgalanDetecting Molecules (IOI16_molecules)C++14
9 / 100
1 ms288 KiB
#include<bits/stdc++.h> #include "molecules.h" using namespace std; typedef long long int ll; #define debug(x) cerr << #x << " = " << (x) << endl vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); vector<pair<int, int>> arr(n); for (int i = 0; i < n; i++) { arr[i] = { w[i], i }; } sort(arr.begin(), arr.end()); ll sum = 0; vector<int> ans; int i = 0; for (; i < n; i++) { if (sum + arr[i].first >= l) break; sum += arr[i].first; ans.push_back(arr[i].second); } for (; i < n; i++) { if (sum + arr[i].first >= l) { sum += arr[i].first; ans.push_back(arr[i].second); break; } } // debug(sum); if (sum >= l && sum <= u) { return ans; } return vector<int>(0); }
#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...