# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
90796 | 2018-12-24T13:00:31 Z | RAkhshon | Bank (IZhO14_bank) | C++14 | 2 ms | 532 KB |
#include<bits/stdc++.h> #define ll long long #define ld long double #define st string #define fr first #define se second #define INF 1000000000 using namespace std; ll a[101101], b[101101], dp[101101]; int main() { //freopen("1.txt", "r", stdin); //freopen("division.out", "w", stdout); ll n, m; scanf("%lld %lld", &n, &m); for(ll i = 1; i <= n; i ++){ scanf("%lld", &a[i]); } for(ll i = 1; i <= m; i ++){ scanf("%lld", &b[i]); } sort(b+1,b+1+m); ll s = a[1]; for(ll j = 1; j <= m; j ++) for(ll i = 1; i <= s; i ++){ if(dp[i]==0) dp[i]=INF; if(i >= b[j] && dp[i]!=INF) {dp[i]=dp[i];} else if(i >= b[j] && dp[i-b[j]] == b[j] ) break ; else if(i >= b[j] && dp[i-b[j]]!=INF ) dp[i]=b[j]; } if(dp[s] != INF) printf("YES"); else printf("NO"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 1 ms | 380 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 500 KB | Output is correct |
2 | Correct | 2 ms | 500 KB | Output is correct |
3 | Correct | 1 ms | 500 KB | Output is correct |
4 | Incorrect | 1 ms | 500 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 500 KB | Output is correct |
2 | Correct | 1 ms | 500 KB | Output is correct |
3 | Correct | 2 ms | 500 KB | Output is correct |
4 | Correct | 2 ms | 532 KB | Output is correct |
5 | Incorrect | 2 ms | 532 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 1 ms | 380 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |