이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define nl '\n'
#define pb push_back
#define E exit(0)
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define sz(s) (s).size()
using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const int N=5e5+5;
const int INF=1e9+7;
const int eps=1e-6;
int dp[N];
void solve() {
int n,m,a;
cin>>n>>m>>a;
int b[m+1];
for (int i=1;i<=m;i++) cin>>b[i];
dp[0]=1;
for (int i=1;i<=m;i++) {
for (int w=a;w>=0;w--) {
if (dp[w-b[i]]==1 && w-b[i]>=0) {
dp[w]=1;
}
}
}
if (dp[a]==1) cout<<"YES";
else cout<<"NO";
cout<<nl;
}
ll test=1;
int main () {
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
ios_base::sync_with_stdio(0);
cin.tie();
// cin>>test;
while (test--) solve();
return 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... |