제출 #651343

#제출 시각아이디문제언어결과실행 시간메모리
651343ayallaDetecting Molecules (IOI16_molecules)C++14
9 / 100
1 ms300 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; #define ll long long int vector<int> find_subset(int l, int u, vector<int> w) { int r = u; int n = w.size(); set<pair<ll, ll>> s; ll sum = 0; for (int i = 0; i < n; i++) { s.insert({w[i], i}); sum += w[i]; } vector<bool> vis(n, 1); while (sum > r) { ll dif = sum - r; auto it = s.lower_bound({dif, -1}); if (it != s.end() && (sum - (*it).first) >= l && (sum - (*it).first) <= r) { pair<ll, ll> x = *it; sum -= x.first; vis[x.second] = 0; break; } else { pair<ll, ll> x = *s.begin(); sum -= x.first; vis[x.second] = 0; s.erase(x); } } vector<int> ans; if (sum < l) return ans; for (int i = 0; i < n; i++) { if (vis[i]) ans.push_back(i); } 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...