# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
5027 | 2014-01-28T13:03:00 Z | ainta | Bank (IZhO14_bank) | C++ | 180 ms | 560 KB |
#pragma warning(disable:4996) #include<stdio.h> #include<algorithm> using namespace std; int n, m, a[20], b[20], o[1010]; bool v[20]; bool DFS(int x, int C); bool Do(int x, int S, int p, int C, int cnt){ int i; if (!S){ if (DFS(x + 1, C - cnt))return true; return false; } if (cnt == C - (n - x) * 2 + 2)return false; for (i = p; i < m; i++){ if (!v[i] && S >= b[i]){ v[i] = true; if (Do(x, S - b[i], i + 1, C, cnt + 1))return true; v[i] = false; } } return false; } bool DFS(int x, int C){ if (x == n){ return true; } if ((n - x) * 2 > C)return false; return Do(x, a[x], 0, C, 0); } int main(){ int i, j; scanf("%d%d", &n, &m); int t; for (i = 0; i < n; i++){ scanf("%d", &t); o[t]++; } for (i = 0; i < m; i++){ scanf("%d", &t); o[t]--; } n = 0, m = 0; for (i = 1; i <= 1000; i++){ if (o[i]){ while (o[i] > 0)a[n++] = i, o[i]--; while (o[i] < 0)b[m++] = i, o[i]++; } } printf(DFS(0, m)?"YES" : "NO"); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 372 KB | Output is correct |
3 | Correct | 1 ms | 408 KB | Output is correct |
4 | Correct | 1 ms | 456 KB | Output is correct |
5 | Correct | 1 ms | 516 KB | Output is correct |
6 | Correct | 1 ms | 516 KB | Output is correct |
7 | Correct | 1 ms | 516 KB | Output is correct |
8 | Correct | 1 ms | 516 KB | Output is correct |
9 | Correct | 8 ms | 516 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 516 KB | Output is correct |
2 | Correct | 1 ms | 516 KB | Output is correct |
3 | Correct | 1 ms | 516 KB | Output is correct |
4 | Correct | 1 ms | 560 KB | Output is correct |
5 | Correct | 1 ms | 560 KB | Output is correct |
6 | Correct | 1 ms | 560 KB | Output is correct |
7 | Correct | 1 ms | 560 KB | Output is correct |
8 | Correct | 2 ms | 560 KB | Output is correct |
9 | Correct | 2 ms | 560 KB | Output is correct |
10 | Correct | 2 ms | 560 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 560 KB | Output is correct |
2 | Correct | 1 ms | 560 KB | Output is correct |
3 | Correct | 2 ms | 560 KB | Output is correct |
4 | Correct | 2 ms | 560 KB | Output is correct |
5 | Correct | 2 ms | 560 KB | Output is correct |
6 | Correct | 2 ms | 560 KB | Output is correct |
7 | Correct | 2 ms | 560 KB | Output is correct |
8 | Correct | 2 ms | 560 KB | Output is correct |
9 | Correct | 2 ms | 560 KB | Output is correct |
10 | Correct | 2 ms | 560 KB | Output is correct |
11 | Correct | 2 ms | 560 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 372 KB | Output is correct |
3 | Correct | 1 ms | 408 KB | Output is correct |
4 | Correct | 1 ms | 456 KB | Output is correct |
5 | Correct | 1 ms | 516 KB | Output is correct |
6 | Correct | 1 ms | 516 KB | Output is correct |
7 | Correct | 1 ms | 516 KB | Output is correct |
8 | Correct | 1 ms | 516 KB | Output is correct |
9 | Correct | 8 ms | 516 KB | Output is correct |
10 | Correct | 1 ms | 516 KB | Output is correct |
11 | Correct | 1 ms | 516 KB | Output is correct |
12 | Correct | 1 ms | 516 KB | Output is correct |
13 | Correct | 1 ms | 560 KB | Output is correct |
14 | Correct | 1 ms | 560 KB | Output is correct |
15 | Correct | 1 ms | 560 KB | Output is correct |
16 | Correct | 1 ms | 560 KB | Output is correct |
17 | Correct | 2 ms | 560 KB | Output is correct |
18 | Correct | 2 ms | 560 KB | Output is correct |
19 | Correct | 2 ms | 560 KB | Output is correct |
20 | Correct | 2 ms | 560 KB | Output is correct |
21 | Correct | 1 ms | 560 KB | Output is correct |
22 | Correct | 2 ms | 560 KB | Output is correct |
23 | Correct | 2 ms | 560 KB | Output is correct |
24 | Correct | 2 ms | 560 KB | Output is correct |
25 | Correct | 2 ms | 560 KB | Output is correct |
26 | Correct | 2 ms | 560 KB | Output is correct |
27 | Correct | 2 ms | 560 KB | Output is correct |
28 | Correct | 2 ms | 560 KB | Output is correct |
29 | Correct | 2 ms | 560 KB | Output is correct |
30 | Correct | 2 ms | 560 KB | Output is correct |
31 | Correct | 2 ms | 560 KB | Output is correct |
32 | Correct | 2 ms | 560 KB | Output is correct |
33 | Correct | 2 ms | 560 KB | Output is correct |
34 | Correct | 2 ms | 560 KB | Output is correct |
35 | Correct | 2 ms | 560 KB | Output is correct |
36 | Correct | 2 ms | 560 KB | Output is correct |
37 | Correct | 1 ms | 560 KB | Output is correct |
38 | Correct | 2 ms | 560 KB | Output is correct |
39 | Correct | 2 ms | 560 KB | Output is correct |
40 | Correct | 2 ms | 560 KB | Output is correct |
41 | Correct | 2 ms | 560 KB | Output is correct |
42 | Correct | 180 ms | 560 KB | Output is correct |
43 | Correct | 2 ms | 560 KB | Output is correct |
44 | Correct | 2 ms | 560 KB | Output is correct |
45 | Correct | 2 ms | 560 KB | Output is correct |
46 | Correct | 2 ms | 560 KB | Output is correct |
47 | Correct | 2 ms | 560 KB | Output is correct |
48 | Correct | 1 ms | 560 KB | Output is correct |
49 | Correct | 2 ms | 560 KB | Output is correct |
50 | Correct | 2 ms | 560 KB | Output is correct |
51 | Correct | 1 ms | 560 KB | Output is correct |
52 | Correct | 1 ms | 560 KB | Output is correct |
53 | Correct | 1 ms | 560 KB | Output is correct |
54 | Correct | 1 ms | 560 KB | Output is correct |
55 | Correct | 1 ms | 560 KB | Output is correct |
56 | Correct | 1 ms | 560 KB | Output is correct |
57 | Correct | 1 ms | 560 KB | Output is correct |
58 | Correct | 2 ms | 560 KB | Output is correct |