Submission #1088547

#TimeUsernameProblemLanguageResultExecution timeMemory
1088547LucasLeDetecting Molecules (IOI16_molecules)C++17
100 / 100
39 ms7484 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; const long long INF = 1e15; vector<int> find_subset(int l, int u, vector<int> w) { vector<pair<long long, int>> v; int n = (int)w.size(); for (int i = 0; i < n; ++i) v.push_back({w[i], i}); v.push_back({INF, n}); sort(v.begin(), v.end()); long long pref = 0, suff = 0; for (int i = 0; i < n; ++i) { pref += v[i].first; suff += v[n - 1 - i].first; if (pref <= u && suff >= l) { vector<int> res; for (int j = i; j < n; ++j) { if (pref >= l) { for (int k = j - i; k <= j; ++k) res.push_back(v[k].second); return res; } pref += v[j + 1].first - v[j - i].first; } } } 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...