Submission #834574

#TimeUsernameProblemLanguageResultExecution timeMemory
834574erdemkirazDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms300 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> ii; vector<int> find_subset(int L, int R, vector<int> v_o) { return {}; ll l = L; ll r = R; vector<ii> v; for(int it = 0; it < (int) v_o.size() - 1; it++) { v.push_back({v_o[it], it}); } sort(v.begin(), v.end()); assert(v.back().first - v[0].first <= r - l); if(v[0].first > R) return {}; if(v[0].first >= L) return {v[0].second}; if(v.back().first >= L) { assert(v.back().first <= R); return {v.back().second}; } assert(v.back().first < L); ll sum = 0; multiset<int> taken; int until = -1; for(int i = 0; i < (int) v.size(); i++) { if(sum + v[i].first > r) break; taken.insert(v[i].second); sum += v[i].first; until = i; } if(sum >= l) { vector<int> res; for(auto x : taken) { res.push_back(x); } return res; } if(until == -1 or (until == (int) v.size() - 1 and sum < l)) return {}; int l_it = 0; int r_it = (int) v.size() - 1; while(sum < l and r_it > until and l_it <= until) { taken.insert(v[r_it].second); sum += v[r_it--].first; taken.erase(taken.find(v[l_it].second)); sum -= v[l_it++].first; } if(sum < l) return {}; assert(sum <= r); vector<int> res; for(auto x : taken) { res.push_back(x); } return res; }
#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...