제출 #1024227

#제출 시각아이디문제언어결과실행 시간메모리
1024227vaneaDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms604 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; using ll = long long; vector<int> find_subset(int l, int u, vector<int> w) { deque<int> ans; vector<pair<ll, int>> v; int n = w.size(); for(int i = 0; i < n; i++) { v.push_back({w[i], i}); } sort(v.begin(), v.end()); int i = 0, j = 1; ll curr = v[0].first; ans.push_back({v[0].second}); while(i < n && j < n) { if(curr >= l && curr <= u) break; else if(curr < l) { curr += v[j].first; ans.push_back(v[j].second); ++j; } else if(curr > u) { curr -= v[i].first; ans.pop_front(); ++i; } } if(curr >= l && curr <= u) { vector<int> res; while(!ans.empty()) { auto node = ans.back(); ans.pop_back(); res.push_back(node); } return res; } return {}; }
#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...