Submission #209230

#TimeUsernameProblemLanguageResultExecution timeMemory
209230my99nDetecting Molecules (IOI16_molecules)C++14
100 / 100
67 ms5628 KiB
#include<bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); vector<pair<int,int>> s(n); for (int i = 0; i < n; i++) s[i] = {w[i], i}; sort(s.begin(), s.end()); int a = 0, b = -1; long long sum = 0; deque<int> ans; while (1) { // cerr << a << ' ' << b << ' ' << sum << endl; if (a < b and sum > u) sum -= s[a++].first, ans.pop_front(); else if (b < (n-1) and sum < l) sum += s[++b].first, ans.push_back(s[b].second); else if (l <= sum and sum <= u) return (vector<int>){ans.begin(), ans.end()}; else break; } return 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...