제출 #676156

#제출 시각아이디문제언어결과실행 시간메모리
676156hxy123123은행 (IZhO14_bank)C++14
0 / 100
5 ms8500 KiB
#include<bits/stdc++.h> using namespace std; const int N=(1<<20); int dp[N],l[N]; int n,m,a[21],b[21]; void solve(){ scanf("%d%d",&n,&m); for(int i=1;i<=n;i++) scanf("%d",&a[i]); for(int i=0;i<m;i++) scanf("%d",&b[i]); memset(dp,-1,sizeof dp); memset(l,-1,sizeof l); dp[0]=0; l[0]=0; for(int i=0;i<(1<<m);i++){ for(int j=0;j<m;j++){ if((i&(1<<j))==0) continue; int k=i-(1<<j); if(dp[k]==-1) continue; if(l[k]+b[j]<a[dp[k]+1]){ dp[i]=max(dp[k],dp[i]); l[i]=a[dp[k]+1]-l[k]-b[j]; } else if(l[k]+b[j]==a[dp[k]+1]){ l[i]=0; dp[i]=max(dp[i],dp[k]+1); } if(dp[i]==n){ cout<<"YES"<<endl; return ; } } } cout<<"NO"<<endl; return ; } int main(){ solve(); }

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

bank.cpp: In function 'void solve()':
bank.cpp:7:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    7 |  scanf("%d%d",&n,&m);
      |  ~~~~~^~~~~~~~~~~~~~
bank.cpp:8:29: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |  for(int i=1;i<=n;i++) scanf("%d",&a[i]);
      |                        ~~~~~^~~~~~~~~~~~
bank.cpp:9:29: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |  for(int i=0;i<m;i++)  scanf("%d",&b[i]);
      |                        ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...