Submission #568460

#TimeUsernameProblemLanguageResultExecution timeMemory
568460Trisanu_DasDetecting Molecules (IOI16_molecules)C++17
100 / 100
45 ms4784 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; #define ll long long int vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); vector <int> p(n); for (int i = 0; i < n; ++i) p[i] = i; sort(p.begin(), p.end(), [&](int u, int v) { return w[u] < w[v]; }); ll sum = 0; vector <int> ans; for (int i = 0, j = 0; i < n; ++i) { sum += w[p[i]]; while (j <= i && sum > u) { sum -= w[p[j]]; ++j; } if (sum >= l) { for (int k = j; k <= i; ++k) ans.push_back(p[k]); return ans; } } 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...