Submission #821340

#TimeUsernameProblemLanguageResultExecution timeMemory
821340KerimDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms272 KiB
#include "molecules.h" #include "bits/stdc++.h" #define ll long long using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); vector<int> ind(n); for (int i = 0; i < n; i++) ind[i] = i; sort(ind.begin(), ind.end(), [&](int x, int y){ return (w[x] < w[y]); }); vector<int> answer; ll pref_sum = 0; for (int i = 0; i < n; i++){ ll sum = pref_sum; if (sum > u) break; for (int j = n-1; j >= i; j--){ sum += w[ind[j]]; if (sum > u) break; if (sum >= l){ for (int h = 0; h < i; h++) answer.push_back(ind[h]); for (int h = j; h < n; h++) answer.push_back(ind[h]); return answer; } } } return vector<int>{}; }
#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...