Submission #62157

#TimeUsernameProblemLanguageResultExecution timeMemory
62157ernestvwDetecting Molecules (IOI16_molecules)C++11
100 / 100
95 ms7948 KiB
#include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { vector<int> ans; vector<pair<int, int>> W; int n = (int)w.size(); for(int i = 0; i < n; i++) W.push_back({w[i], i}); sort(W.begin(), W.end()); vector<long long> prefix(n+1); prefix[0] = 0; for(int i = 1; i <= n; i++) prefix[i] = prefix[i-1] + (long long)W[i-1].first; for(int i = 0; i < n; i++) { long long remove = prefix[i]; if(prefix[n] - remove < l) continue; int cur = i; if(W[i].first < l) { for(int jump = 20; jump >= 0; jump--) if((1 << jump) + cur < n and prefix[(1 << jump) + cur + 1] - remove < l) cur += (1 << jump); cur++; } if(cur == n) continue; if(prefix[cur + 1] - remove > u) continue; for(int j = i; j <= cur; j++) ans.push_back(W[j].second); return ans; } 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...