Submission #1088635

#TimeUsernameProblemLanguageResultExecution timeMemory
1088635vjudge1Bank (IZhO14_bank)C++17
0 / 100
3 ms348 KiB
#include <bits/stdc++.h> using namespace std; using pii = pair<int,int>; const int maxn = 20,inf = 1e9; int n,m; pii dp[1 << maxn]; int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cin >> n >> m; vector<int> s(n),c(m); for(int &i : s) cin >> i; for(int &i : c) cin >> i; dp[0] = {0,0}; //qual a proxima pessoa e a soma atual for(int i = 1;i < (1 << m);i++){ dp[i] = {-1,-1}; for(int j = 0;j < m;j++) if(i & (1 << j)){ int last = i ^ (1 << j); pii x = dp[last]; if(x.first == x.second && x.first == -1) continue; x.second += j; if(x.second == s[x.first]){ x.first++; x.second = 0; } if(x.first == n){ cout << "YES"; return 0; } dp[i] = max(dp[i],x); } } cout << "NO"; 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...