# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
390700 | ahmet | Bank (IZhO14_bank) | C++14 | 25 ms | 360 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;
#define zaman cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds "
#define rep(i,n) for(long long (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long (i)=(a); (i)<=(b); ++(i))
#define endl '\n'
#define ll long long
#define pb push_back
#define pii pair<ll,ll>
#define mp make_pair
const int mx=1e6+6;
int a[22],b[22],dp[mx];
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
int n,m;cin >> n >> m;
ref(i,1,n)cin >> a[i];
ref(i,1,m)cin >> b[i];
sort(b+1,b+m+1);
dp[0]=1;
for(int i=m;i>0;--i){
int bank=b[i];
for(int s=1e6;s>0;--s){
if(s-bank<0)break;
if(dp[s-bank]){dp[s]=1;}
}
}
if(dp[a[1]])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... |