# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
580543 | 2022-06-21T12:07:25 Z | yutabi | Bank (IZhO14_bank) | C++14 | 1000 ms | 468 KB |
#include <bits/stdc++.h> using namespace std; #define pb push_back typedef long long ll; typedef pair <ll,ll> ii; int n; int m; vector <int> s; vector <int> x; bool DP2[1001][1001]; int main() { scanf("%d %d",&n,&m); if(n==1){ for(int i=0;i<n;i++) { int a; scanf(" %d",&a); s.pb(a); } for(int i=0;i<m;i++) { int a; scanf(" %d",&a); x.pb(a); } DP2[0][0]=1; for(int i=0;i<m;i++) { for(int j=0;j<1001;j++) { if(x[i]+j<1001 && DP2[i][j]==1) { DP2[i+1][x[i]+j]=1; } if(DP2[i][j]) { DP2[i+1][j]=1; } } } if(DP2[m][s[0]]) { printf("YES"); } else { printf("NO"); }} else{ bool table[n+1][1<<m]; bool DP[n+1][1<<m]; for(int i=0;i<1<<m;i++) { DP[0][i]=1; table[0][i]=0; } for(int j=1;j<n+1;j++) { for(int i=0;i<1<<m;i++) { DP[j][i]=0; table[j][i]=0; } } for(int i=0;i<n;i++) { int a; scanf(" %d",&a); s.pb(a); } for(int i=0;i<m;i++) { int a; scanf(" %d",&a); x.pb(a); } for(int i=0;i<1<<m;i++) { int a=i; int sum=0; for(int j=0;j<m;j++,a/=2) { if(a%2) { sum+=x[j]; } } for(int j=0;j<n;j++) { if(s[j]==sum) { table[j][i]=1; } } } for(int i=0;i<n;i++) { for(int j=0;j<1<<m;j++) { for(int k=0;k<1<<m;k++) { if(((j&k)==0) && DP[i][j] && table[i][k]) { DP[i+1][j|k]=1; } } } } if(DP[n][(1<<m)-1]==1) { printf("YES"); } else { printf("NO"); }} }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 212 KB | Output is correct |
2 | Correct | 4 ms | 212 KB | Output is correct |
3 | Correct | 5 ms | 212 KB | Output is correct |
4 | Correct | 5 ms | 320 KB | Output is correct |
5 | Correct | 8 ms | 212 KB | Output is correct |
6 | Correct | 5 ms | 212 KB | Output is correct |
7 | Correct | 4 ms | 212 KB | Output is correct |
8 | Correct | 5 ms | 228 KB | Output is correct |
9 | Correct | 3 ms | 212 KB | Output is correct |
10 | Correct | 5 ms | 316 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1092 ms | 468 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 5 ms | 212 KB | Output is correct |
11 | Correct | 4 ms | 212 KB | Output is correct |
12 | Correct | 5 ms | 212 KB | Output is correct |
13 | Correct | 5 ms | 320 KB | Output is correct |
14 | Correct | 8 ms | 212 KB | Output is correct |
15 | Correct | 5 ms | 212 KB | Output is correct |
16 | Correct | 4 ms | 212 KB | Output is correct |
17 | Correct | 5 ms | 228 KB | Output is correct |
18 | Correct | 3 ms | 212 KB | Output is correct |
19 | Correct | 5 ms | 316 KB | Output is correct |
20 | Execution timed out | 1092 ms | 468 KB | Time limit exceeded |
21 | Halted | 0 ms | 0 KB | - |