Submission #1030894

#TimeUsernameProblemLanguageResultExecution timeMemory
1030894kiethm07Bank (IZhO14_bank)C++11
100 / 100
84 ms8644 KiB
#include <bits/stdc++.h> #define pii pair<int,int> #define iii pair<int,pii> #define fi first #define se second #define vi vector<int> #define vii vector<pii> #define pb(i) push_back(i) #define all(x) x.begin(),x.end() #define TEXT "a" using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; const int inf = 1e9 + 7; const ld eps = 1e-8; const double pi = acos(-1); const int N = 20; int n,m; int a[N], b[N]; int dp[1 << N], r[1 << N]; int main(){ cin.tie(0) -> sync_with_stdio(0); if (fopen(TEXT".inp","r")){ freopen(TEXT".inp","r",stdin); freopen(TEXT".out","w",stdout); } cin >> n >> m; for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < m; i++) cin >> b[i]; memset(dp,-1,sizeof(dp)); dp[0] = 0; for (int mask = 0; mask < (1 << m); mask++){ for (int i = 0; i < m; i++){ if (!(mask & (1 << i))) continue; int submask = mask ^ (1 << i); if (dp[submask] == -1) continue; int p = dp[submask]; int cur = r[submask] + b[i]; if (cur < a[p]){ dp[mask] = dp[submask]; r[mask] = cur; } if (cur == a[p]){ dp[mask] = dp[submask] + 1; r[mask] = 0; } } if (dp[mask] == n){ cout << "YES\n"; return 0; } } cout << "NO\n"; return 0; }

Compilation message (stderr)

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