제출 #330386

#제출 시각아이디문제언어결과실행 시간메모리
330386Vince729은행 (IZhO14_bank)C++11
71 / 100
1070 ms86656 KiB
#include<iostream> #include<cstdio> #include<string> #include<vector> #include<cstring> #include<algorithm> #include<set> #include<map> #include<complex> using namespace std; typedef long long ll; typedef complex<double> pt; #define x() real() #define y() imag() #define smx(a, b) a = max(a, b) #define smn(a, b) a = min(a, b) #define in(mp, v) mp.find(v) != mp.end() const int MAXN = 20; const int MOD = 1000000007; int n, m, a[MAXN+1], b[MAXN]; int dp[MAXN+1][1<<MAXN]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i]; for (int j = 0; j < m; j++) cin >> b[j]; memset(dp, 0xbf, sizeof(dp)); dp[0][0] = 0; bool found = false; for (int i = 1; i <= n; i++) { found = false; for (int k = 0; k < (1<<m); k++) { if (dp[i-1][k] == a[i-1]) { dp[i][k] = 0; } else { for (int j = 0; j < m; j++) { if (k & (1<<j)) { smx(dp[i][k], dp[i][k ^ (1<<j)] + b[j]); } } } if (dp[i][k] == a[i]) found = true; //cout << k << " " << dp[i][k] << endl; } } if (found) { cout << "YES" << endl; } else cout << "NO" << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...