Submission #636093

#TimeUsernameProblemLanguageResultExecution timeMemory
636093nehasaneDetecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms212 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector <int> ans; int n = w.size(), p = 0; vector <pair <int, int>> wt(n); for (int i = 0; i < n; i++) wt[i] = {w[i], i}; sort(wt.begin(), wt.end()); long long sum = 0; for (int i = n-1; i >= 0; i--) { if (sum + wt[i].first >= l) { p = i; break; } sum += wt[i].first; ans.push_back(wt[i].second); } for (int i = p; i >= 0; i--) { if (sum + wt[i].first >= l && sum + wt[i].first <= u) { ans.push_back(wt[i].second); sum += wt[i].first; break; } } 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...