Submission #485179

#TimeUsernameProblemLanguageResultExecution timeMemory
485179XIIBank (IZhO14_bank)C++17
0 / 100
1 ms348 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define fi first #define se second #define mp make_pair #define eb emplace_back #define ALL(x) (x).begin(), (x).end() #define FOR(i, a, b) for(int i = (a); i < (b); ++i) #define FORU(i, a, b) for(int i = (a); i <= (b); ++i) #define FORD(i, a, b) for(int i = (a); i >= (b); --i) #define IOS cin.tie(0)->sync_with_stdio(false); #define PROB "IZhO14_bank" void Fi(){ if(fopen(PROB".inp", "r")){ freopen(PROB".inp", "r", stdin); freopen(PROB".out", "w", stdout); } } const int N = 20; const int V = 1000 + 1; bool dp[1 << N][N]; vector<int> adj[V]; int n, m; int a[N], b[N]; int main(){ IOS; Fi(); cin >> n >> m; FOR(i, 0, n) cin >> a[i]; FOR(i, 0, m) cin >> b[i]; FOR(mask, 1, 1 << m){ int sum = 0; FOR(i, 0, m) if(mask & (1 << i)) sum += b[i]; if(sum < N) adj[sum].eb(mask); } FOR(i, 0, n){ FOR(mask, 1, 1 << m){ for(int s: adj[a[i]]) if((mask & s) == s){ if(!i) dp[mask][i] = true; else dp[mask][i] |= dp[mask ^ s][i - 1]; } } } bool ans = false; FOR(mask, 1, 1 << m) ans |= dp[mask][n - 1]; if(ans) cout << "YES"; else cout << "NO"; return 0; }

Compilation message (stderr)

bank.cpp: In function 'void Fi()':
bank.cpp:20:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         freopen(PROB".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bank.cpp:21:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         freopen(PROB".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...