Submission #1056090

#TimeUsernameProblemLanguageResultExecution timeMemory
1056090vjudge1Bank (IZhO14_bank)C++17
100 / 100
81 ms11696 KiB
#include<bits/stdc++.h> using namespace std; #define se second #define fi first const int Nmax = 1e6 + 207; const int LogN = 17; int n , m; int a[30] , b[30]; bool c[1 << 21]; pair <int , int> dp[1 << 21]; main() { cin >> n >> m; for (int i = 1 ; i <= n ; i++) cin >> a[i]; for (int i = 0 ; i < m ; i++) cin >> b[i]; c[0] = true; dp[0] = {1 , 0}; for (int mask = 1 ; mask < (1 << m ) ; mask++) { for (int i = 0 ; i < m; i++) { if (mask & (1 << i)) { if (c[mask ^ (1 << i)]) { pair <int , int> tmp = dp[mask ^ (1 << i)]; tmp.se += b[i]; if (tmp.se < a[tmp.fi]) { c[mask] = true; dp[mask] = tmp; } else if (tmp.se == a[tmp.fi]) { c[mask] = true; dp[mask] = {tmp.fi + 1 , 0}; } } } } } bool v = false; for (int mask = 1 ; mask < (1 << m) ; mask++) if (dp[mask].fi > n) { cout << "YES"; return 0; } cout << "NO" << endl; }

Compilation message (stderr)

bank.cpp:14:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   14 | main()
      | ^~~~
bank.cpp: In function 'int main()':
bank.cpp:49:10: warning: unused variable 'v' [-Wunused-variable]
   49 |     bool v = 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...