Submission #752645

#TimeUsernameProblemLanguageResultExecution timeMemory
752645I_love_DaneliyaBank (IZhO14_bank)C++17
100 / 100
383 ms181056 KiB
// Problem: X - Bank #include <bits/stdc++.h> using namespace std ; #define ff first #define ss second #define ll long long #define pb push_back #define lb lower_bound #define ub upper_bound #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define ones(x) __builtin_popcount(x) #define remove(v) v.erase(unique(all(v)), v.end()) #define rep(i, a, b) for(int i = a; i <= b; i++) #define per(i, a, b) for(int i = a; i >= b; i--) #ifdef local #include "C:\debug.h" #else #define dbg(x...) 42 #endif #define int ll const int N = 1e5 + 2 ; const int P = 29 ; const int MOD = 1e9 + 7 ; int n , m , a[21] , b[21] , pref[21] , dp[22][(1 << 20) + 1]; int go(int i , int mask , int cur) { if(cur == pref[i]) { dbg(mask , pref[i]) ; dp[i][mask] = 1 ; i++ ; } if(i > n) { cout << "YES\n" ; exit(0) ; } if(~dp[i][mask]) return dp[i][mask] ; int ans = 0 ; rep(j , 0 , m - 1) { if(!(mask >> j & 1) && cur + b[j + 1] <= pref[i]) { ans |= go(i , mask ^ (1 << j) , cur + b[j + 1]) ; } } dp[i][mask] = ans ; return ans ; } void solve(){ memset(*dp, -1, sizeof(dp)) ; cin >> n >> m ; rep(i , 1 , n) cin >> a[i] ; rep(i , 1 , n) pref[i] = pref[i - 1] + a[i] ; rep(i , 1 , m) cin >> b[i] ; int ok = go(1, 0, 0) ; cout << "NO\n" ; } signed main () { // freopen(".in","r",stdin) ; // freopen(".out","w",stdout) ; ios::sync_with_stdio(false) ; cin.tie(0) ; int test = 1 ; // cin >> test ; for(int i = 1 ; i <= test ; i++) { solve() ; } }

Compilation message (stderr)

bank.cpp: In function 'long long int go(long long int, long long int, long long int)':
bank.cpp:23:19: warning: statement has no effect [-Wunused-value]
   23 | #define dbg(x...) 42
      |                   ^~
bank.cpp:36:9: note: in expansion of macro 'dbg'
   36 |         dbg(mask , pref[i]) ;
      |         ^~~
bank.cpp: In function 'void solve()':
bank.cpp:61:9: warning: unused variable 'ok' [-Wunused-variable]
   61 |     int ok = go(1, 0, 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...