Submission #392182

#TimeUsernameProblemLanguageResultExecution timeMemory
392182HegdahlDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms332 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; using ll = long long; vector<int> find_subset(int _l, int _u, vector<int> w) { ll l = _l, u = _u; int n = w.size(); ll mn = 1LL<<60; for (int v : w) mn = min(mn, (ll)v); if (mn > u) return {}; vector<int> idxs(n); iota(idxs.begin(), idxs.end(), 0); sort(idxs.begin(), idxs.end(), [&](int i, int j){ return w[i] < w[j]; }); ll s = 0; vector<int> ans; int last = -1; for (int _i = 0; _i < n; ++_i) { int i = idxs[_i]; if (s + w[i] > u) { last = _i; break; } s += w[i]; ans.push_back(i); if (s >= l) return ans; } int _i = 0; while (_i+last < n) { s -= w[ans[_i]]; ans[_i] = idxs[_i+last]; s += w[ans[_i]]; ++_i; if (s >= l) return ans; } 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...