제출 #579872

#제출 시각아이디문제언어결과실행 시간메모리
579872karrigan은행 (IZhO14_bank)C++14
0 / 100
4 ms468 KiB
#include <bits/stdc++.h> using namespace std; vector<long long>c[1009]; long long a[1009]; long long b[1009]; long long dp[21][1<<20]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); freopen("bank.in","r",stdin); freopen("bank.out","w",stdout); int n,m; cin>>n>>m; for (int i=1;i<=n;i++)cin>>a[i]; for (int i=1;i<=m;i++)cin>>b[i]; for (int i=0;i<(1<<m);i++){ long long temp=0; for (int j=0;j<m;j++){ if (i>>j&1){ temp+=b[j+1]; } } if (temp<=1000){ c[temp].push_back(i); } } dp[0][0]=1; for (int i=1;i<=n;i++){ for (int j=0;j<(1<<m);j++){ if (dp[i-1][j]==1){ long long temp=(1<<m)-1-j; bool flag=false; for (auto v:c[a[i]]){ if ((temp&v)==v){ dp[i][j+v]=1; flag=true; } } if (flag==false){ cout<<"NO"; return 0; } } } } for (int j=0;j<(1<<m);j++){ if (dp[n][j]==1){ cout<<"YES"; return 0; } } cout<<"NO"; return 0; }

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

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