제출 #696087

#제출 시각아이디문제언어결과실행 시간메모리
696087aedmhsn은행 (IZhO14_bank)C++17
100 / 100
133 ms8496 KiB
#include <bits/stdc++.h> using namespace std; #define A first #define B second #define MP make_pair #define ms(a, x) memset(a, x, sizeof(a)) #define boost() ios_base::sync_with_stdio(false); cin.tie(); cout.tie() typedef long long ll; typedef long double ld; typedef pair<int, int> pii; typedef pair<long long, long long> pll; typedef pair<long double, long double> pld; const int INF = 0x3f3f3f3f; const ll LLINF = 0x3f3f3f3f3f3f3f3f; const double PI = acos(-1); const int mxN=20; pii dp[(1 << mxN)]; int main(){ int n, m; cin >> n >> m; vector <int> v(n); vector <int> coins(m); for(int i=0; i<n; i++) cin >> v[i]; for(int i=0; i<m; i++) cin >> coins[i]; bool valid=false; for(int i=0; i<(1 << m); i++){ for(int j=0; j<m; j++){ if((i & (1 << j))) continue; int nmsk = (i | (1 << j)); if(dp[i].B + coins[j] == v[dp[i].A]){ dp[nmsk] = max(dp[nmsk], {dp[i].A+1, 0}); } else if(dp[i].B + coins[j] < v[dp[i].A]){ dp[nmsk] = max(dp[nmsk], {dp[i].A, dp[i].B+coins[j]}); } if(dp[nmsk].A == n){ cout << "YES"; return 0; } } } cout << "NO"; }

컴파일 시 표준 에러 (stderr) 메시지

bank.cpp: In function 'int main()':
bank.cpp:37:10: warning: unused variable 'valid' [-Wunused-variable]
   37 |     bool valid=false;
      |          ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...