Submission #821343

#TimeUsernameProblemLanguageResultExecution timeMemory
821343KerimDetecting Molecules (IOI16_molecules)C++17
69 / 100
1071 ms2796 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; if (sum >= l){ for (int h = 0; h < i; h++) answer.push_back(ind[h]); return answer; } 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; } } pref_sum += w[ind[i]]; } 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...