Submission #82903

#TimeUsernameProblemLanguageResultExecution timeMemory
82903ToadDaveskiBank (IZhO14_bank)C++14
0 / 100
3 ms1296 KiB
#include <bits/stdc++.h> #define ll long long using namespace std; ll dp[45][45][2501],a[45],b[45]; int main() { ll n,m,i,j,g; cin>>n>>m; for(i=1;i<=n;i++) cin>>a[i]; for(i=1;i<=m;i++) cin>>b[i]; dp[0][0][0]=1; for(i=1;i<=m;i++) for(j=0;j<=n;j++) { for(g=0;g<=a[j];g++) { dp[i][j][g]=dp[i-1][j][g]; if (g==b[i]) dp[i][j][g]=max(dp[i][j][g],dp[i-1][j-1][a[j-1]]); if (g>b[i])dp[i][j][g]=max(dp[i][j][g],dp[i-1][j][g-b[i]]); } } if (dp[m][n][a[n]]) cout<<"Yes"; else cout<<"No"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...