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;
#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define OK puts("OK");
#define sz(s) (int)s.size()
#define pii pair<int,int>
#define int long long
#define all(s) s.begin(), s.end()
#define allr(s) s.rbegin(), s.rend()
#define rep(i,n) for (i=0;i<(n);++i)
#define rep1(i,n) for (i=1;i<=(n);++i)
#define ret return
#define nemeshay ios::sync_with_stdio(0),cin.tie(0);
const int N=1e6+12,INF=1e9+7;
int q[N],a[N],b[N],e[N],g[N],x[N];
bool dp[N];
main(){
nemeshay
int n,i,j,k,m,ans=0;
cin>>n>>m;
if (n>m){
cout <<"NO";ret 0;
}
rep(i,n)cin>>a[i];
dp[0]=1;
rep(i,m){
cin>>k;
for (j=20000;j>=0;--j){
if (dp[j]){
dp[j+k]=1;
}
}
}
if (dp[a[0]])
cout <<"YES";
else cout <<"NO";
}
Compilation message (stderr)
bank.cpp:20:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
bank.cpp: In function 'int main()':
bank.cpp:22:19: warning: unused variable 'ans' [-Wunused-variable]
int n,i,j,k,m,ans=0;
^~~| # | 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... |