Submission #717751

#TimeUsernameProblemLanguageResultExecution timeMemory
717751tigarBank (IZhO14_bank)C++14
100 / 100
117 ms8672 KiB
#include <bits/stdc++.h> using namespace std; int people[30], pay[30]; int n, m; pair<int, int>dp[(1<<21)]; int main() { #define name "bank" if(fopen(name".inp", "r")){ freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } ios_base::sync_with_stdio(); cin.tie(); cout.tie(); cin>>n>>m; for(int i=0; i<n; i++)cin>>people[i]; for(int j=0; j<m; j++)cin>>pay[j]; bool dobraa=false; for(int i=0; i<(1<<m); i++) { if(dp[i].first==n){dobraa=true; break;} for(int j=0; j<m; j++) { if(((1<<j)&i))continue; pair<int, int>pp; if(people[dp[i].first]==dp[i].second+pay[j]){pp={dp[i].first+1, 0};} else pp={dp[i].first, dp[i].second+pay[j]}; dp[(i|(1<<j))]=max(pp, dp[(i|(1<<j))]); } } if(dobraa)cout<<"YES\n"; else cout<<"NO\n"; return 0; } /*1 8 9 1 1 1 1 1 1 1 1*/

Compilation message (stderr)

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