제출 #1004728

#제출 시각아이디문제언어결과실행 시간메모리
1004728liaochengle은행 (IZhO14_bank)C++14
0 / 100
30 ms436 KiB
#include <bits/stdc++.h> using namespace std; const int N =20; const int M =21; //前m个banknote, N int dp[M][1<<N]; int salary[N]; int banknote[M]; int main(){ freopen("bank.in","r",stdin); freopen("bank.out","w",stdout); int n, m; cin>>n>>m; for(int i=0;i<n;i++) cin>>salary[i]; for(int i=0;i<m;i++) cin>>banknote[i]; for(int i=0;i<=m;i++) dp[i][0] = 1; for(int bk=1;bk<=m;bk++){ for(int s=1;s<(1<<n);s++){ dp[bk][s] = dp[bk-1][s]; for(int p=0;p<n;p++){ //cout<<'p'<<p<<'\n'; if((s&(1<<p))==0) continue; int ind = bk-1; int sum = 0; while(sum < salary[p] && ind>=0){ sum += banknote[ind]; ind--; } if(ind<0 || sum != salary[p]){ continue; } ind++; //cout<<"now "<<bk<<' '<<bitset<5>(s)<<' '<<bitset<5>(s^(1<<p))<<' '<<(ind-1)<<' '<<dp[ind][s^(1<<p)]<<'\n'; dp[bk][s] = max(dp[bk][s], dp[ind][s^(1<<p)]); } } } if(dp[m][(1<<n)-1]) cout<<"YES"; else cout<<"NO"; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

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