Submission #884216

#TimeUsernameProblemLanguageResultExecution timeMemory
884216preskoBank (IZhO14_bank)C++14
46 / 100
1 ms2404 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; } } } for(int i=1;i<=n;i++) { if(dp[m][a[i]]==0){cout<<"NO\n";return 0;} } cout<<"YES\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...