Submission #883729

#TimeUsernameProblemLanguageResultExecution timeMemory
883729preskoBank (IZhO14_bank)C++14
19 / 100
1 ms2552 KiB
#include<iostream> #include<bits/stdc++.h> #define MAXN 1010 using namespace std; bool dp[MAXN][20010]; int a[MAXN]; int b[MAXN]; int main() { int n,m,sum=0; ios_base::sync_with_stdio(false); cin.tie(0); cin>>n>>m; for(int i=1;i<=n;i++) { cin>>a[i]; sum+=a[i]; dp[i][0]=1; } dp[0][0]=1; for(int i=1;i<=m;i++) { cin>>b[i]; } for(int i=1;i<=m;i++) { dp[i][b[i]]=1; for(int j=1;j<=sum;j++) { if(dp[i-1][j]) { dp[i][j]=1; dp[i][j+b[i]]=1; } } } if(dp[m][a[1]])cout<<"YES\n"; else cout<<"NO\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...