Submission #589781

#TimeUsernameProblemLanguageResultExecution timeMemory
589781KrisjanisPDetecting Molecules (IOI16_molecules)C++14
46 / 100
110 ms696 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; bool possible[10001]; ll current[10001]; vector<int> find_subset(int l, int u, vector<int> w) { ll n = w.size(); possible[0] = 1; current[0] = -1; for(ll i=0;i<n;i++) { for(ll j=10000-w[i];j>=0;j--) { if(!possible[j]) continue; if(possible[j+w[i]]) continue; possible[j+w[i]]=1; current[j+w[i]]=i; } } //cout<<"hello\n"; for(ll i=l;i<=u;i++) { if(possible[i]) { vector<int> res; ll j = i; while(j!=0) { res.push_back(current[j]); j = j - w[current[j]]; //cout<<j<<" "<<current[j]<<"\n"; } return res; 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...