제출 #1024232

#제출 시각아이디문제언어결과실행 시간메모리
1024232vaneaDetecting Molecules (IOI16_molecules)C++14
9 / 100
1 ms348 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) { set<pair<int, int>> s; 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; s.insert(v[0]); while(i < n && j < n) { if(curr >= l && curr <= u) break; else if(curr < l) { curr += v[j].first; s.insert(v[j]); ++j; } else if(curr > u) { curr -= s.begin()->first; s.erase(s.begin()); ++i; } } if(curr >= l && curr <= u) { vector<int> res; for(auto it : s) res.push_back(it.second); return res; } return {}; } /* int main() { vector<int> ans = find_subset(15, 17, {6, 8, 8, 7}); for(auto it : ans) { cout << it << ' '; } }*/
#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...