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<algorithm>
#include<iostream>
#include<vector>
#include<string>
#include<random>
#include<cmath>
#include<stack>
#include<map>
#include <iomanip>
#include <queue>
#include <set>
using namespace std;
using ll = long long;
using ull = unsigned long long;
ll mod = 1e9 + 7;
ll pv(ll a, ll b) {
if (b == 0)return 1;
ll res = (pv(a, b / 2));
if (b % 2) {
return (((res * res) % mod) * (a % mod)) % mod;
}
else {
return (res * res) % mod;
}
}
void solve() {
int n, m; cin >> n >> m;
int ap; cin >> ap;
vector<int>v(m),dp(10000);
for (int i = 0; i < m; i++)cin >> v[i];
dp[0] = 1;
for (int i = 0; i < m; i++) {
for (int j = 1000; j >= v[i]; j--) {
if (dp[j - v[i]] == 1)dp[j] = 1;
}
}
//cout << dp[6] << endl;
if (dp[ap])cout << "YES" << endl;
else cout << "NO" << endl;
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cin.tie(nullptr);
ll _ = 1;
//cin >> _;
while (_--)
{
solve();
}
}
# | 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... |