Submission #870868

#TimeUsernameProblemLanguageResultExecution timeMemory
870868sleepntsheepBank (IZhO14_bank)C++17
0 / 100
96 ms175272 KiB
#include <iostream> #include <cstring> #include <vector> #include <algorithm> #include <deque> #include <set> #include <utility> #include <array> using namespace std; #define ALL(x) x.begin(), x.end() #define ShinLena cin.tie(nullptr)->sync_with_stdio(false); using i64 = long long; int z=4, n, m, a[21], b[20], dp[21][1<<20]; int main() { ShinLena; cin >> n >> m; memset(dp, 0x86, sizeof dp); for (int i = 1; i <= n; ++i) cin >> a[i]; for (int i = 0; i < m; ++i) cin >> b[i]; dp[0][0] = 0; for (int i = 0; i <= n; ++i) { for (int j = 0; j < (1 << m); ++j) { if (i) if (dp[i-1][j] == a[i]) dp[i][j] = 0; for (int k = 0; k < j; ++k) { if (j & (1 << k)) { int p = j&~(1<<k); dp[i][j] = max(dp[i][j], dp[i][p] + b[k]); } } if (i == n && !dp[i][j]) z = 0; } } cout << &"YES\0NO"[z]; 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...