제출 #939473

#제출 시각아이디문제언어결과실행 시간메모리
939473ifateenDetecting Molecules (IOI16_molecules)C++14
0 / 100
0 ms348 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; vector<int> find_subset(int l, int u, std::vector<int> w) { vector<int> ans; vector<long long> pref(w.size()); vector<pair<int, int>> arr(w.size()); for (size_t i = 0; i < w.size(); i++) { arr[i] = {w[i], i}; } sort(begin(arr), end(arr)); int len = -1; pref[0] = arr[0].first; for (size_t i = 1; i < w.size(); i++) pref[i] = pref[i - 1] + arr[i].first; for (size_t i = 0; i < w.size(); i++) if (pref[i] > u) { len = i; break; } if (len == -1) { ans.resize(w.size()); iota(begin(ans), end(ans), 0); return ans; } for (size_t i = 0; i <= w.size() - len; i++) if (l <= pref[i + len] - pref[i] && pref[i + len] - pref[i] <= u) { for (size_t j = i; j < i + len; j++) ans.push_back(arr[j].second); break; } 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...