제출 #491947

#제출 시각아이디문제언어결과실행 시간메모리
491947VirvDetecting Molecules (IOI16_molecules)C++17
69 / 100
2 ms460 KiB
#include <algorithm> #include <cstdint> #include <numeric> #include <vector> #include "molecules.h" std::vector<int> find_subset(int l, int u, std::vector<int> w) { std::vector<uint32_t> p(w.size()); iota(p.begin(), p.end(), 0); sort(p.begin(), p.end(), [&](auto a, auto b) { return w[a] < w[b]; }); int T{}; std::vector<int> S{}; size_t i{}; while (i < p.size() && T + w[p[i]] <= u) { T += w[p[i]]; S.push_back(p[i]); ++i; } if (S.size() == 0) return {}; while (i < p.size() && T < l) { T += w[p[i]] - w[S[i % S.size()]]; S[i % S.size()] = p[i]; ++i; } return l <= T && T <= u ? S : std::vector<int>{}; }
#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...