Submission #145645

#TimeUsernameProblemLanguageResultExecution timeMemory
145645karmaDetecting Molecules (IOI16_molecules)C++14
0 / 100
1075 ms380 KiB
#include<bits/stdc++.h> #include "molecules.h" #define ll long long #define mp make_pair using namespace std; typedef pair<int, int> pii; vector<int> find_subset(int l, int u, vector<int> w) { vector<int> ans; set<pii, greater<pii>> _Max, Max; set<pii> Min, _Min; int n; ll s = 0; pii top; n = w.size(); for(int i = 0; i < n; ++i) { if(s + w[i] <= l) Min.insert(mp(w[i], i)), Max.insert(mp(w[i], i)), s += w[i]; else _Max.insert(mp(w[i], i)), _Min.insert(mp(w[i], i)); } while(s < l || s > u) { if(s < l) { top = *Min.begin(); Min.erase(top), Max.erase(top); s -= top.first; _Max.insert(top), _Min.insert(top); top = *_Max.begin(); s += top.first; _Min.erase(top), _Max.erase(top); Max.insert(top), Min.insert(top); } else { top = *Max.begin(); s -= top.first; Min.erase(top), Max.erase(top); _Min.insert(top), _Max.insert(top); top = *_Min.begin(); _Min.erase(top), _Max.erase(top); s += top.first; Max.insert(top), Min.insert(top); } } for(pii v: Max) ans.push_back(v.second + 1); return ans; }
#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...