Submission #704088

#TimeUsernameProblemLanguageResultExecution timeMemory
704088thrasherr_1Bank (IZhO14_bank)C++17
0 / 100
103 ms262144 KiB
// Problem: Elevator Rides // #pragma GCC optimize("O3") // #pragma GCC target("avx2") #include <bits/stdc++.h> using namespace std ; #define ff first #define ss second #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 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 long long const int N = 2e6 + 2 ; const int MOD = 1e9 + 7 ; const int P = 1007 ; int n , m , a[21] , b[21] , pref[21] ; int dp[21][(1 << 21)] ; int go(int i , int mask , int cur) { if(cur == pref[i]) { dp[i][mask] = 1 ; i++ ; } if(i > n) { return 1 ; } if(dp[i][mask] != -1) 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 dp[i][mask] ; } void solve(){ rep(i , 0 , 20) { rep(j , 0 , (1 << 21) - 1) { dp[i][j] = -1 ; } } cin >> n >> m ; rep(i , 1 , n) cin >> a[i] ; rep(i , 1 , m) cin >> b[i] ; rep(i , 1 , n) pref[i] = pref[i - 1] + a[i] ; bool ok = go(1 , 0 , 0) ; if(*max_element(dp[n] , dp[n] + (1 << 21))) { cout << "YES\n" ; }else{ cout << "NO\n" ; } } signed main () { // 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 'void solve()':
bank.cpp:64:10: warning: unused variable 'ok' [-Wunused-variable]
   64 |     bool 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...