제출 #436429

#제출 시각아이디문제언어결과실행 시간메모리
4364292qbingxuanDetecting Molecules (IOI16_molecules)C++14
0 / 100
1 ms204 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<size_t> id(w.size()); iota(id.begin(), id.end(), 0); sort(id.begin(), id.end(), [&w](size_t a, size_t b) { return w[a] < w[b]; }); long long sum = 0; size_t cnt = 0; vector<int> res; for (size_t i: id) { if (sum + w[i] < l) { sum += w[i]; ++cnt; res.push_back(i); } else break; } if (cnt == w.size() || cnt == 0) return {}; cerr << cnt << '\n'; cerr << sum << '\n'; sum -= w[id.front()]; sum += w[id.back()]; if (sum < l || sum > u) return {}; assert (l <= sum && sum <= u); res.erase(res.begin()); res.push_back(id.back()); 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...