Submission #636100

#TimeUsernameProblemLanguageResultExecution timeMemory
636100nehasaneDetecting Molecules (IOI16_molecules)C++14
9 / 100
1 ms212 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { vector <int> ans; int n = w.size(), p = -1; 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 = 0; i <= p; 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...