Submission #569509

#TimeUsernameProblemLanguageResultExecution timeMemory
569509penguin133Bank (IZhO14_bank)C++14
100 / 100
163 ms16704 KiB
#include <bits/stdc++.h> using namespace std; #define int long long pair<int, int> dp[2000005]; int A[25], B[25]; main(){ int n,m;cin >> n >> m; for(int i=0;i<n;i++)cin >> A[i]; for(int i=0;i<m;i++)cin >> B[i]; for(int i=0;i<(1<<m);i++){ dp[i] = make_pair(0, 0); for(int j=0;j<m;j++){ if(!(i >> j & 1))continue; int k = i^(1 << j); pair<int, int> ans = dp[k]; ans.second += B[j]; if(A[ans.first] == ans.second){ ans.first++; ans.second = 0; } dp[i] = max(dp[i], ans); } } for(int i=0;i<(1<<m);i++){ if(dp[i].first == n){ cout << "YES"; return 0; } } cout << "NO"; }

Compilation message (stderr)

bank.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...