Submission #710038

#TimeUsernameProblemLanguageResultExecution timeMemory
710038BaytoroDetecting Molecules (IOI16_molecules)C++17
69 / 100
40 ms5540 KiB
#include "molecules.h" #include <bits/stdc++.h> //#include "grader.cpp" using namespace std; vector<pair<int,int>> vec; vector<int> get(int l, int r){ vector<int> ans; for(int i=l;i<=r;i++) ans.push_back(vec[i].second); sort(ans.begin(),ans.end()); return ans; } vector<int> find_subset(int v, int u, vector<int> w) { int n=w.size(); int sum=0; for(int i=0;i<n;i++) vec.push_back({w[i],i}); sort(vec.begin(),vec.end()); int l=0; for(int r=0;r<n;r++){ sum+=vec[r].first; if(sum<v) continue; if(v<=sum && sum<=u){ return get(l,r); } else{ while(l<=r && sum>u){ sum-=vec[l].first; l++; } if(v<=sum && sum<=u){ return get(l,r); } } } 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...