# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
172672 | 2020-01-02T10:32:12 Z | abacaba | 은행 (IZhO14_bank) | C++14 | 276 ms | 5584 KB |
#include <iostream> #include <string> #include <unordered_map> #include <unordered_set> #include <cstring> #include <chrono> #include <vector> #include <map> #include <random> #include <set> #include <algorithm> #include <math.h> #include <cstdio> #include <stdio.h> #include <queue> #include <bitset> #include <cstdlib> #include <deque> #include <cassert> #include <stack> using namespace std; #define max3(a, b, c) max(a, max(b, c)) #define min3(a, b, c) min(a, min(b, c)) #define mp make_pair #define f first #define se second #define pb push_back #define ppb pop_back #define ll long long #define y1 abcde #define ull unsigned long long #define cntbit(x) __builtin_popcount(x) #define endl '\n' #define uset unordered_set #define umap unordered_map #define all(x) x.begin(), x.end() #define pii pair<int, int> #define ld long double #define pll pair<long long, long long> const int inf = 2e9; const int mod = 1e9 + 7; const int N = 20; int n, m, a[N], b[N], cur, sum[1 << N]; bool dp[1 << N]; main() { scanf("%d %d\n", &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 mask = 0; mask < (1 << m); ++mask) for(int i = 0; i < m; ++i) if((1 << i) & mask) sum[mask] += b[i]; dp[0] = true; for(int i = 0; i < n; ++i) { for(int mask = 0; mask < (1 << m); ++mask) { if(sum[mask] < cur || !dp[mask]) continue; int sum_now = sum[mask] - cur; for(int j = 0; j < m; ++j) if(((1 << j) & mask) == 0) if(sum_now + b[j] <= a[i]) dp[mask | (1 << j)] = true; } cur += a[i]; } for(int mask = 0; mask < (1 << m); ++mask) if(sum[mask] == cur && dp[mask]) return puts("YES"), 0; puts("NO"); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 252 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 504 KB | Output is correct |
5 | Correct | 79 ms | 4472 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 121 ms | 5368 KB | Output is correct |
9 | Correct | 167 ms | 5484 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 2 ms | 376 KB | Output is correct |
5 | Correct | 2 ms | 376 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 380 KB | Output is correct |
8 | Correct | 2 ms | 376 KB | Output is correct |
9 | Correct | 2 ms | 376 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 4 ms | 376 KB | Output is correct |
3 | Correct | 4 ms | 376 KB | Output is correct |
4 | Correct | 4 ms | 376 KB | Output is correct |
5 | Correct | 3 ms | 376 KB | Output is correct |
6 | Correct | 3 ms | 376 KB | Output is correct |
7 | Correct | 4 ms | 376 KB | Output is correct |
8 | Correct | 3 ms | 376 KB | Output is correct |
9 | Correct | 3 ms | 376 KB | Output is correct |
10 | Correct | 3 ms | 376 KB | Output is correct |
11 | Correct | 4 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 252 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
4 | Correct | 5 ms | 504 KB | Output is correct |
5 | Correct | 79 ms | 4472 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 121 ms | 5368 KB | Output is correct |
9 | Correct | 167 ms | 5484 KB | Output is correct |
10 | Correct | 2 ms | 376 KB | Output is correct |
11 | Correct | 2 ms | 376 KB | Output is correct |
12 | Correct | 2 ms | 376 KB | Output is correct |
13 | Correct | 2 ms | 376 KB | Output is correct |
14 | Correct | 2 ms | 376 KB | Output is correct |
15 | Correct | 2 ms | 376 KB | Output is correct |
16 | Correct | 2 ms | 380 KB | Output is correct |
17 | Correct | 2 ms | 376 KB | Output is correct |
18 | Correct | 2 ms | 376 KB | Output is correct |
19 | Correct | 2 ms | 376 KB | Output is correct |
20 | Correct | 3 ms | 376 KB | Output is correct |
21 | Correct | 4 ms | 376 KB | Output is correct |
22 | Correct | 4 ms | 376 KB | Output is correct |
23 | Correct | 4 ms | 376 KB | Output is correct |
24 | Correct | 3 ms | 376 KB | Output is correct |
25 | Correct | 3 ms | 376 KB | Output is correct |
26 | Correct | 4 ms | 376 KB | Output is correct |
27 | Correct | 3 ms | 376 KB | Output is correct |
28 | Correct | 3 ms | 376 KB | Output is correct |
29 | Correct | 3 ms | 376 KB | Output is correct |
30 | Correct | 4 ms | 376 KB | Output is correct |
31 | Correct | 154 ms | 5496 KB | Output is correct |
32 | Correct | 169 ms | 5584 KB | Output is correct |
33 | Correct | 95 ms | 5476 KB | Output is correct |
34 | Correct | 92 ms | 4912 KB | Output is correct |
35 | Correct | 96 ms | 5136 KB | Output is correct |
36 | Correct | 107 ms | 4844 KB | Output is correct |
37 | Correct | 80 ms | 4680 KB | Output is correct |
38 | Correct | 82 ms | 4400 KB | Output is correct |
39 | Correct | 128 ms | 5496 KB | Output is correct |
40 | Correct | 97 ms | 4664 KB | Output is correct |
41 | Correct | 111 ms | 4764 KB | Output is correct |
42 | Correct | 140 ms | 5528 KB | Output is correct |
43 | Correct | 97 ms | 5240 KB | Output is correct |
44 | Correct | 98 ms | 4472 KB | Output is correct |
45 | Correct | 130 ms | 5496 KB | Output is correct |
46 | Correct | 109 ms | 5500 KB | Output is correct |
47 | Correct | 97 ms | 4652 KB | Output is correct |
48 | Correct | 94 ms | 5484 KB | Output is correct |
49 | Correct | 81 ms | 4600 KB | Output is correct |
50 | Correct | 268 ms | 5512 KB | Output is correct |
51 | Correct | 90 ms | 4636 KB | Output is correct |
52 | Correct | 97 ms | 5496 KB | Output is correct |
53 | Correct | 204 ms | 5556 KB | Output is correct |
54 | Correct | 255 ms | 5416 KB | Output is correct |
55 | Correct | 273 ms | 5568 KB | Output is correct |
56 | Correct | 274 ms | 5496 KB | Output is correct |
57 | Correct | 276 ms | 5496 KB | Output is correct |
58 | Correct | 267 ms | 5496 KB | Output is correct |