Submission #1001439

#TimeUsernameProblemLanguageResultExecution timeMemory
1001439reginoxBank (IZhO14_bank)C++17
0 / 100
2 ms2396 KiB
#include<bits/stdc++.h> #define ll long long #define ld long double #define all(v) begin(v), end(v) #define pi pair<int, int> #define vi vector<int> #define task "test" using namespace std; const int maxn = 20; int n, m, a[maxn], b[maxn], pf[maxn]; bool dp[maxn][1<<maxn]; int cost[1<<maxn]; int main(){ if(fopen(task".inp","r")){ freopen(task".inp","r",stdin); freopen(task".out","w",stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for(int i = 1; i <= n; i++) cin >> a[i], pf[i] = pf[i-1] + a[i]; for(int i = 1; i <= m; i++) cin >> b[i]; for(int i = 0; i < 1<<m; i++){ for(int j = 0; j < m; j++){ if(i & (1<<j)) cost[i] += b[j+1]; } } dp[0][0] = true; for(int i = 1; i <= n; i++){ for(int j = 0; j < 1<<m; j++){ if(cost[j] != pf[i]) continue; for(int sub = j; sub > 0; sub = (sub-1) & j){ if(dp[i-1][sub] && cost[sub^j] == a[i]) dp[i][j] = true; } } } for(int i = 0; i < 1<<m; i++){ if(dp[n][i]){ cout << "YES"; return 0; } } cout << "NO"; return 0; }

Compilation message (stderr)

bank.cpp: In function 'int main()':
bank.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         freopen(task".inp","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
bank.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen(task".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...