# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
5016 | 2014-01-27T15:46:35 Z | tncks0121 | Bank (IZhO14_bank) | C++ | 3 ms | 576 KB |
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <string.h> #include <memory.h> #include <math.h> #include <assert.h> #include <stack> #include <queue> #include <map> #include <set> #include <algorithm> #include <string> #include <functional> #include <vector> #include <deque> #include <utility> #include <bitset> #include <limits.h> #include <time.h> using namespace std; typedef long long ll; typedef unsigned long long llu; typedef double lf; typedef unsigned int uint; typedef long double llf; typedef pair<int, int> pii; int N, M, A[20], B[20]; bool S[20][1<<20]; bool Table[20][1<<20]; int main() { freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); scanf("%d%d", &N, &M); for(int i = 0; i < N; i++) scanf("%d", A+i); for(int i = 0; i < M; i++) scanf("%d", B+i); for(int state = 0; state < (1<<M); state++) { int sum = 0; for(int i = 0; i < M; i++) if(state & (1<<i)) sum += B[i]; for(int i = 0; i < N; i++) if(A[i] == sum) S[i][state] = 1; } // Table[i][state]: A[1..i] 지불, 현재 state만큼의 수표 사용 for(int state = 0; state < (1<<M); state++) Table[0][state] = S[0][state]; for(int i = 1; i < N; i++) { for(int state = 0; state < (1<<M); state++) { for(int p = 0; p < (1<<M) && Table[i][state]; p++) { if(S[i][p] && ((p & state) == p) && Table[i-1][p^state]) Table[i][state] = 1; } } } for(int state = 0; state < (1<<M); state++) if(Table[N-1][state]) return puts("YES"), 0; puts("NO"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 576 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 576 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |