Submission #17451

#TimeUsernameProblemLanguageResultExecution timeMemory
17451azecoderBank (IZhO14_bank)C++98
19 / 100
34 ms588 KiB
#include <iostream> #define MAXN 21 #define intt long long using namespace std ; intt a[MAXN] , b[MAXN] , n , m , f ; intt d ( intt p ) { if ( p == m ) f = 1 ; if ( f ) return 0 ; for ( int i = 0 ; i <= ( 1 << ( n - 1 ) ) ; i ++ ) { if ( f ) return 0 ; intt x = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( 1 << j ) & i ) { x += a[j] ; if ( a[j] == -1 ) { x = -1 ; break ; } } } if ( x == -1 ) continue ; if ( x == b[p] ) { intt z[MAXN] ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( 1 << j ) & i ) z[j] = a[j] , a[j] = -1 ; } d ( p + 1 ) ; if ( f ) return 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( ( 1 << j ) & i ) a[j] = z[j] ; } } } return 0 ; } int main () { cin >> m >> n ; for ( int i = 0 ; i < m ; i ++ ) cin >> b[i] ; for ( int i = 0 ; i < n ; i ++ ) cin >> a[i] ; d ( 0 ) ; if ( f ) cout << "YES\n" ; else cout << "NO\n" ; return 0 ; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...