Submission #493669

#TimeUsernameProblemLanguageResultExecution timeMemory
493669IwanttobreakfreeDetecting Molecules (IOI16_molecules)C++14
9 / 100
1 ms296 KiB
#include "molecules.h" #include <iostream> #include <vector> #include <algorithm> using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { int n=w.size(); vector<pair<int,int> >mol(n); for(int i=0;i<n;i++)mol[i]={w[i],i}; sort(mol.begin(),mol.end()); int ans=0,j=0; for(int i=0;i<n;i++){ while(j<n&&mol[j].first+ans<=u){ ans+=mol[j].first; j++; } //cout<<ans<<' '; if(ans>=l){ vector<int> sol; for(int k=i;k<j;k++)sol.push_back(mol[k].second); return sol; } } return vector<int>(0); } /*int main(){ vector<int> v={5,5,6,6}; int l=15,r=16; vector<int> ans=find_subset(l,r,v); for(int x:ans)cout<<x<<' '; } */
#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...