Submission #678973

#TimeUsernameProblemLanguageResultExecution timeMemory
678973hgmhcDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms304 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { int n = size(w); vector<int> I(n); iota(begin(I),end(I),0); sort(begin(I),end(I),[&](int x, int y) { return w[x] > w[y]; }); int i, j = 0, k; long long s = 0; for (i = 0; i < n; ++i) { k = I[i]; s += w[k]; if (s >= l) break; } while (true) { if (s <= u) { vector<int> res(i-j+1); for (int x = j; x <= i; ++x) res[x-j] = I[x]; return res; } if (i+1 == n) break; s -= w[I[j++]], s += w[I[++i]]; } return {}; }
#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...