Submission #788380

#TimeUsernameProblemLanguageResultExecution timeMemory
788380BulaDetecting Molecules (IOI16_molecules)C++17
19 / 100
1085 ms17308 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() //#define int ll const ll mod=1e9+7; vector<int> find_subset(int l,int u,vector<int> w){ int n=(int)w.size(); vector<int> v(n+1); for(int i=1;i<=n;i++) v[i]=w[i-1]; int dp[n+1][u+1]; for(int i=0;i<=n;i++){ for(int j=1;j<=u;j++){ dp[i][j]=0; } } vector<int> ans; for(int i=1;i<=n;i++){ for(int j=u;j>=1;j--){ if(dp[i-1][j]>0) dp[i][j]=1; if(j==v[i]) dp[i][j]=2; if(j>v[i]) dp[i][j]=max(dp[i][j],dp[i-1][j-v[i]]); } } int sum=0; for(int i=l;i<=u;i++){ if(dp[n][i]>0){ sum=i; break; } } int i=n; while(sum!=0){ if(dp[i][sum]==2){ sum-=v[i]; ans.pb(i-1); i--; }else{ i--; } } 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...