Submission #1067477

#TimeUsernameProblemLanguageResultExecution timeMemory
1067477horezusholBank (IZhO14_bank)C++14
19 / 100
65 ms8636 KiB
#include<bits/stdc++.h> #define F first #define S second #define SZ(x) int((x).size()) const char nl = '\n'; using namespace std; int sum[(1 << 20)]; vector<int> v[1010]; int a[20], b[20]; int n, m; bool dp[1010][(1 << 20)]; bool muba(int N, int M, vector<int> A, vector<int> B) { // input n = N, m = M; for (int i = 0; i < n; i ++) { a[i] = A[i]; } for (int i = 0; i < m; i ++) { b[i] = B[i]; } // end of input for (int mask = 0; mask < (1 << m); mask ++) { for (int i = 0; i < m; i ++) { if (mask & (1 << i)) sum[mask] += b[i]; } } for (int i = 0; i < n; i ++) { for (int mask = 0; mask < (1 << m); mask ++) { if (sum[mask] == a[i]) { v[a[i]].push_back(mask); } } } for (auto el : v[a[0]]) { dp[0][el] = true; } for (int mask = 0; mask < (1 << m); mask ++) { if (dp[0][mask]) { for (int i = 0; i < m; i ++) { if (mask != (mask | (1 << i))) { // cout << mask << " " << (mask | (1 << i)) << nl; } dp[0][mask | (1 << i)] = true; } } } int tot = 0; for (int i = 0; i < n; i ++) { for (int mask = 0; mask < (1 << m); mask ++) { if (i > 0) { if (!dp[i-1][mask]) continue; } else { if (!dp[i][mask]) continue; } if (sum[mask] - tot == a[i]) { dp[i][mask] = true; for (int j = 0; j < m; j ++) { dp[i][mask | (1 << j)] = true; } } } tot += a[i]; } if (dp[n-1][(1 << m)-1]) { return true; } else { return false; } } bool usaco(int N, int M, vector<int> A, vector<int> B) { } signed main() { int nn, mm; cin >> nn >> mm; vector<int> aa(nn), bb(mm); for (int i = 0; i < nn; i ++) { cin >> aa[i]; } for (int i = 0; i < mm; i ++) { cin >> bb[i]; } if (muba(nn, mm, aa, bb)) { cout << "YES"; } else { cout << "NO"; } }

Compilation message (stderr)

bank.cpp: In function 'bool usaco(int, int, std::vector<int>, std::vector<int>)':
bank.cpp:76:1: warning: no return statement in function returning non-void [-Wreturn-type]
   76 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...