Submission #821350

#TimeUsernameProblemLanguageResultExecution timeMemory
821350KerimDetecting Molecules (IOI16_molecules)C++17
100 / 100
38 ms2892 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 sum = 0; int pos = 0; for (int i = 0; i < n; i++){ sum += w[ind[i]]; while (sum > u) sum -= w[ind[pos++]]; if (sum >= l){ for (int j = pos; j <= i; j++) answer.push_back(ind[j]); 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...