제출 #867282

#제출 시각아이디문제언어결과실행 시간메모리
867282AtabayRajabliDetecting Molecules (IOI16_molecules)C++17
69 / 100
78 ms12904 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; std::vector<int> find_subset(int L, int U, std::vector<int> w) { int n = w.size(); std::vector<pair<int, int>> v(n); for(int i = 0; i<n; i++) { v[i] = make_pair(w[i], i); } sort(v.begin(), v.end()); set<int> s; int l = 0, r = 0, sum = 0; while(r < n) { sum += v[r].first; s.insert(v[r].second); while(l <= r && sum > U) { sum -= v[l].first; s.erase(v[l].second); l++; } if(L <= sum && sum <= U) { vector<int> ans; for(int i : s)ans.push_back(i); return ans; } r++; } return std::vector<int>(0); }
#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...