Submission #1092937

#TimeUsernameProblemLanguageResultExecution timeMemory
1092937sinatbtfardBank (IZhO14_bank)C++17
100 / 100
87 ms8792 KiB
#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] = lft[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)

bank.cpp: In function 'int main()':
bank.cpp:7:6: warning: unused variable 't' [-Wunused-variable]
    7 |  int t, n, m;
      |      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...