# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1092935 | sinatbtfard | Bank (IZhO14_bank) | C++17 | 4 ms | 8648 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main (){
ios_base::sync_with_stdio(0);
int t, n, m;
cin >> n >> m;
vector <int> a(n), b(m), dp(1 << m, -1), lft(1 << m, -1);
for (int &i : a) cin >> i;
for (int &i : b) cin >> i;
dp[0] = 0;
for (int mask = 1; mask < (1 << m); mask++){
for (int i = 0; i < m; i++){
if (!((1 << i) & mask)) continue;
int tmp = mask ^ (1 << i);
if (dp[tmp] == -1) continue;
if (lft[tmp] + b[i] < a[dp[tmp]]){
dp[mask] = dp[tmp];
lft[mask] = lft[tmp] + b[i];
}
else if (lft[tmp] + b[i] == a[dp[tmp]]){
dp[mask] = dp[tmp] + 1;
lft[mask] = 0;
}
}
if (dp[mask] == n)
return cout << "YES", 0;
}
cout << "NO";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |