# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
344291 | katearima | Bank (IZhO14_bank) | C++14 | 1 ms | 368 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N=25;
const int M=1005;
int n, m, a[N], b[N], dp[M] , mx;
main(){
cin>>n>>m;
for(int i=0; i<n; i++){
cin>>a[i];
mx=max(mx, a[i]);
}
//n=1;
for(int i=0; i<m; i++){
cin>>b[i];
}
dp[0]=1;
for(int i=0; i<m; i++){
for(int j=mx; j>=0; j--){
if(j-b[i]<0) continue;
dp[j]+=dp[j-b[i]];
}
}
for(int i=0; i<n; i++) if(dp[a[i]]>0) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |