#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename key>
// for ordered set or indexed set
using ordered_set= tree<key, null_type, less_equal<key>, rb_tree_tag, tree_order_statistics_node_update>; // less_equal
#define f1(n) for(int i=0;i<n;i++)
#define e '\n'
#define f2(m,n,q) for(int i=m;i<n;i+=q)
#define f3(n) for(int j=0;j<n;j++)
#define f4(m,n,q) for(int j=m;j<n;j+=q)
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define pb push_back
#define pi 3.14159265358979323846
//f^=1 == if(f==0)f=1 else f=0
int setbit(int n,int idx,int val){return (val ? ((1LL<<idx)|n):(~(1LL<<idx)&n));}
int getbit(int n,int idx){return ((n>>idx)&1LL);}
typedef long long ll;
const int N=2e5+5;
const int mod=1e9+7;
const int inf=1e9,sqr=448;
const int dx[]={-1,1,0,0};
const int dy[]={0,0,-1,1};
bool cmp(array<int,2> a,array<int,2> b){
if(a[0]==b[0])return a[1]>b[1];
return a[1]/a[0]>b[1]/b[0];
}
int32_t main()
{
speed;
int tt=1,cnt=1;//cin>>tt;
while(tt--){
//freopen("bank.in","r",stdin);
//freopen("bank.out","w",stdout);
int n,m;cin>>n>>m;
int c;cin>>c;
int a[m];f1(m)cin>>a[i];
bool dp[c+1]={};
dp[0]=1;
for(int i=0;i<m;i++){
for(int j=c;j>=a[i];j--){
dp[j]|=dp[j-a[i]];
}
}
cout<<(dp[c] ? "YES":"NO");
}
}
# | 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... |