Submission #856009

#TimeUsernameProblemLanguageResultExecution timeMemory
856009IS_RushdiDetecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms604 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; vector<int> find_subset(int l, int u, std::vector<int> w) { int n = w.size(); vector<pair<int,int>>a; for(int i = 0; i < n; i++) a.push_back({w[i],i}); sort(a.begin(), a.end()); priority_queue<int>pq; int curr = 0; for(int i = n-1; i >= 0; i--){ if(curr < l){ curr += a[i].first; pq.push(i); }else if(curr > u){ curr-=a[pq.top()].first; pq.pop(); curr+=a[i].first; pq.push(i); }else break; } vector<int>ans; while(!pq.empty()){ ans.push_back(a[pq.top()].second); pq.pop(); } return ans; } // int main(){ // }
#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...