제출 #520334

#제출 시각아이디문제언어결과실행 시간메모리
520334krit3379은행 (IZhO14_bank)C++17
100 / 100
102 ms8620 KiB
#include<bits/stdc++.h> using namespace std; #define N 20 int a[N],b[N]; pair<int,int> dp[1<<N]; int main(){ int n,m,i,j,pre; scanf("%d %d",&n,&m); for(i=0;i<n;i++)scanf("%d",&a[i]); for(i=0;i<m;i++)scanf("%d",&b[i]); for(i=0;i<(1<<m);i++){ for(j=0;j<m;j++){ if((i&(1<<j))==0)continue; pre=i^(1<<j); auto [last,sum]=dp[pre]; if(sum+b[j]==a[last]){ dp[i]=max(dp[i],make_pair(last+1,0)); } else{ dp[i]=max(dp[i],make_pair(last,sum+b[j])); } } } if(dp[(1<<m)-1].first==n)printf("YES"); else printf("NO"); return 0; }

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

bank.cpp: In function 'int main()':
bank.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d %d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~
bank.cpp:11:26: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |     for(i=0;i<n;i++)scanf("%d",&a[i]);
      |                     ~~~~~^~~~~~~~~~~~
bank.cpp:12:26: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     for(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...