제출 #1231922

#제출 시각아이디문제언어결과실행 시간메모리
1231922djsksbrbf은행 (IZhO14_bank)C++20
0 / 100
8 ms16712 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair <int, int> pii; #define fi first #define se second #define pb push_back const int MOD = 1e9 + 7; const int MAX = (1ll << 20) + 5; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n >> m; int a[n + 1]; int b[m]; for(int i = 1 ; i <= n ; i++)cin >> a[i]; for(int i = 0 ; i < m ; i++)cin >> b[i]; ll dp[(1ll << m) + 5][2];memset(dp, -1, sizeof(dp)); // 0 is the fulfilled, 1 is the remaining from the last one dp[0][0] = 0; dp[0][1] = 0; bool ans = 0; for(int i = 0 ; i <= (1ll << m) - 1 ; i++){ for(int j = 0 ; j < m ; j++){ if((i & (1ll << j)) == 0)continue; ll prev = (i^ (1ll <<j)); ll cur = dp[prev][1] + b[j]; ll needed = a[dp[prev][0] + 1]; if(cur < needed){ dp[i][0] = dp[prev][0]; dp[i][1] = cur; } else{ dp[i][0] = dp[prev][1] + 1; dp[i][1] = 0; } } if(dp[i][0] == n){ ans = 1; break; } } cout << (ans ? "YES" : "NO") << endl; 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...