# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1017131 | daviedu | Bank (IZhO14_bank) | C11 | 1079 ms | 8784 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 <stdio.h>
#include <string.h>
int dp[1<<20], r[1<<20];
int pay[20], notes[20];
int main(){
memset(dp, -1, sizeof(dp));
int n, m;
scanf("%d %d", &n, &m);
for (int i=0; i<n; i++) scanf("%d", &pay[i]);
for (int i=0; i<m; i++) scanf("%d", ¬es[i]);
int ans=0;
for (int i=0; i<n; i++){
for (int mask=1; mask<(1<<m); mask++){
int p=-2;
int c=-1;
for (int j=0; j<m; j++){
if (mask & (1 << j)){
if (dp[mask ^ (1 << j)] > p){
p = dp[mask ^ (1 << j)];
c = j;
}
}
}
int d = mask ^ (1 << c);
int v = r[d] + notes[c];
if (dp[d] == i) dp[mask] = i, r[mask] = v;
else if (dp[d] == i-1){
if (v == pay[i]) dp[mask] = i, r[mask] = 0;
else dp[mask] = i-1, r[mask] = v;
}
if (dp[mask] == n-1) ans = 1;
}
}
printf("%s\n", (ans? "YES" : "NO"));
return 0;
}
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... |