Submission #431757

#TimeUsernameProblemLanguageResultExecution timeMemory
431757phathnvDetecting Molecules (IOI16_molecules)C++11
100 / 100
53 ms4776 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; vector<int> find_subset(int u, int v, vector<int> w) { int n = w.size(); vector<int> ord(n); iota(ord.begin(), ord.end(), 0); sort(ord.begin(), ord.end(), [&](const int &a, const int &b) { return w[a] < w[b]; }); long long sumL = 0, sumR = 0; for (int i = 1; i <= n; i++) { sumL += w[ord[i - 1]]; sumR += w[ord[n - i]]; if (max(1ll * u, sumL) <= min(1ll * v, sumR)) { vector<int> res; for (int j = 0; j < i; j++) { if (sumL < u) { sumL -= w[ord[j]]; sumL += w[ord[n - 1 - j]]; res.push_back(ord[n - 1 - j]); } else { res.push_back(ord[j]); } } return res; } } return vector<int>(0); }
#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...