# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
254551 |
2020-07-30T08:50:37 Z |
infinite_iq |
Bank (IZhO14_bank) |
C++14 |
|
147 ms |
4480 KB |
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 340
//#define mp make_pair
#define mid (l+r)/2
#define le node * 2
#define ri node * 2 + 1
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
#define all(x) x.begin(), x.end()
#define gc getchar_unlocked
typedef long long ll;
typedef short int si;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef pair<double,ll>pdi;
const ll inf=1e18;
const ll Mod=1e9+7;
const ld Pi=acos(-1);
int n , m ;
int a [21] , b [21] ;
int dp [(1<<20)+9] ;
int bt ( int pos , int mask , int sum ) {
if ( pos == n ) return 1 ;
int &ret = dp [mask] ;
if ( ret != -1 ) return ret ;
ret = 0 ;
for ( int i = 0 ; i < m ; i ++ ) {
if ( ( mask & ( 1 << i ) ) ) C ;
if ( sum + b [i] == a [pos] ) {
ret = max ( ret , bt ( pos + 1 , ( mask | ( 1 << i ) ) , 0 ) ) ;
}
if ( sum + b [i] < a [pos] ) {
ret = max ( ret , bt ( pos , ( mask | ( 1 << i ) ) , sum + b [i] ) ) ;
}
}
return ret ;
}
int main () {
mem ( dp , -1 ) ;
cin >> n >> m ;
for ( int i = 0 ; i < n ; i ++ ) cin >> a [i] ;
for ( int i = 0 ; i < m ; i ++ ) cin >> b [i] ;
cout << ( bt ( 0 , 0 , 0 ) ? "YES" : "NO" ) << endl ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4480 KB |
Output is correct |
2 |
Correct |
2 ms |
4480 KB |
Output is correct |
3 |
Correct |
2 ms |
4480 KB |
Output is correct |
4 |
Correct |
3 ms |
4480 KB |
Output is correct |
5 |
Correct |
3 ms |
4480 KB |
Output is correct |
6 |
Correct |
2 ms |
4352 KB |
Output is correct |
7 |
Correct |
3 ms |
4480 KB |
Output is correct |
8 |
Correct |
63 ms |
4472 KB |
Output is correct |
9 |
Correct |
131 ms |
4472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4480 KB |
Output is correct |
2 |
Correct |
3 ms |
4352 KB |
Output is correct |
3 |
Correct |
3 ms |
4352 KB |
Output is correct |
4 |
Correct |
3 ms |
4480 KB |
Output is correct |
5 |
Correct |
3 ms |
4480 KB |
Output is correct |
6 |
Correct |
3 ms |
4352 KB |
Output is correct |
7 |
Correct |
2 ms |
4480 KB |
Output is correct |
8 |
Correct |
4 ms |
4352 KB |
Output is correct |
9 |
Correct |
3 ms |
4480 KB |
Output is correct |
10 |
Correct |
3 ms |
4352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4480 KB |
Output is correct |
2 |
Correct |
3 ms |
4480 KB |
Output is correct |
3 |
Correct |
3 ms |
4352 KB |
Output is correct |
4 |
Correct |
2 ms |
4352 KB |
Output is correct |
5 |
Correct |
3 ms |
4352 KB |
Output is correct |
6 |
Correct |
3 ms |
4352 KB |
Output is correct |
7 |
Correct |
4 ms |
4352 KB |
Output is correct |
8 |
Correct |
3 ms |
4480 KB |
Output is correct |
9 |
Correct |
3 ms |
4480 KB |
Output is correct |
10 |
Correct |
2 ms |
4352 KB |
Output is correct |
11 |
Correct |
4 ms |
4480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4480 KB |
Output is correct |
2 |
Correct |
2 ms |
4480 KB |
Output is correct |
3 |
Correct |
2 ms |
4480 KB |
Output is correct |
4 |
Correct |
3 ms |
4480 KB |
Output is correct |
5 |
Correct |
3 ms |
4480 KB |
Output is correct |
6 |
Correct |
2 ms |
4352 KB |
Output is correct |
7 |
Correct |
3 ms |
4480 KB |
Output is correct |
8 |
Correct |
63 ms |
4472 KB |
Output is correct |
9 |
Correct |
131 ms |
4472 KB |
Output is correct |
10 |
Correct |
3 ms |
4480 KB |
Output is correct |
11 |
Correct |
3 ms |
4352 KB |
Output is correct |
12 |
Correct |
3 ms |
4352 KB |
Output is correct |
13 |
Correct |
3 ms |
4480 KB |
Output is correct |
14 |
Correct |
3 ms |
4480 KB |
Output is correct |
15 |
Correct |
3 ms |
4352 KB |
Output is correct |
16 |
Correct |
2 ms |
4480 KB |
Output is correct |
17 |
Correct |
4 ms |
4352 KB |
Output is correct |
18 |
Correct |
3 ms |
4480 KB |
Output is correct |
19 |
Correct |
3 ms |
4352 KB |
Output is correct |
20 |
Correct |
2 ms |
4480 KB |
Output is correct |
21 |
Correct |
3 ms |
4480 KB |
Output is correct |
22 |
Correct |
3 ms |
4352 KB |
Output is correct |
23 |
Correct |
2 ms |
4352 KB |
Output is correct |
24 |
Correct |
3 ms |
4352 KB |
Output is correct |
25 |
Correct |
3 ms |
4352 KB |
Output is correct |
26 |
Correct |
4 ms |
4352 KB |
Output is correct |
27 |
Correct |
3 ms |
4480 KB |
Output is correct |
28 |
Correct |
3 ms |
4480 KB |
Output is correct |
29 |
Correct |
2 ms |
4352 KB |
Output is correct |
30 |
Correct |
4 ms |
4480 KB |
Output is correct |
31 |
Correct |
122 ms |
4352 KB |
Output is correct |
32 |
Correct |
140 ms |
4472 KB |
Output is correct |
33 |
Correct |
10 ms |
4480 KB |
Output is correct |
34 |
Correct |
3 ms |
4352 KB |
Output is correct |
35 |
Correct |
4 ms |
4352 KB |
Output is correct |
36 |
Correct |
3 ms |
4352 KB |
Output is correct |
37 |
Correct |
2 ms |
4480 KB |
Output is correct |
38 |
Correct |
3 ms |
4352 KB |
Output is correct |
39 |
Correct |
20 ms |
4480 KB |
Output is correct |
40 |
Correct |
3 ms |
4480 KB |
Output is correct |
41 |
Correct |
3 ms |
4352 KB |
Output is correct |
42 |
Correct |
69 ms |
4472 KB |
Output is correct |
43 |
Correct |
5 ms |
4480 KB |
Output is correct |
44 |
Correct |
3 ms |
4480 KB |
Output is correct |
45 |
Correct |
59 ms |
4472 KB |
Output is correct |
46 |
Correct |
28 ms |
4352 KB |
Output is correct |
47 |
Correct |
2 ms |
4480 KB |
Output is correct |
48 |
Correct |
22 ms |
4352 KB |
Output is correct |
49 |
Correct |
2 ms |
4480 KB |
Output is correct |
50 |
Correct |
144 ms |
4472 KB |
Output is correct |
51 |
Correct |
5 ms |
4480 KB |
Output is correct |
52 |
Correct |
8 ms |
4480 KB |
Output is correct |
53 |
Correct |
140 ms |
4472 KB |
Output is correct |
54 |
Correct |
124 ms |
4472 KB |
Output is correct |
55 |
Correct |
127 ms |
4472 KB |
Output is correct |
56 |
Correct |
123 ms |
4476 KB |
Output is correct |
57 |
Correct |
130 ms |
4464 KB |
Output is correct |
58 |
Correct |
147 ms |
4472 KB |
Output is correct |