제출 #1024115

#제출 시각아이디문제언어결과실행 시간메모리
1024115vaneaDetecting Molecules (IOI16_molecules)C++14
9 / 100
1 ms604 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; using ll = long long; const ll INF = 1e18; vector<int> find_subset(int l1, int u1, vector<int> w2) { vector<ll> w; ll l = l1, u = u1; for(auto it : w2) { w.push_back(it); } set<array<ll, 2>, greater<array<ll, 2>>> s; multiset<pair<ll, int>> w1; int n = w.size(); s.insert({0, 0}); ll ans = 0; for(int i = 0; i < n; i++) { if(w[i] > u) continue; w1.insert({w[i], i}); auto it = s.lower_bound({u-w[i], INF}); if(it != s.end()) { ans = max(ans, w[i]+(*it)[0]); s.insert({(*it)[0]+w[i], w[i]}); } if(it != s.end() && (*it)[0] != 0) s.insert({w[i], w[i]}); } if(ans < l) return {}; vector<int> res; while(ans != 0) { auto it = s.lower_bound({ans, INF}); ll curr = (*it)[1]; ans -= curr; auto it1 = w1.lower_bound({curr, INF}); res.push_back((*it1).second); w1.erase(it1); } sort(res.begin(), res.end()); while(res.size() == 0) {} return res; } /*int main() { int l = 16, u = 16; vector<int> v = {16}; auto ans = find_subset(l, u, v); for(auto it : ans) { cout << it << ' '; } }*/
#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...