제출 #989727

#제출 시각아이디문제언어결과실행 시간메모리
989727Batorgil952은행 (IZhO14_bank)C++14
100 / 100
88 ms8812 KiB
#include<bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair #define ff first #define ss second using namespace std; const int N=21, M=1.5e6; int a[N], b[N]; pair< int, int > dp[M]; int main(){ int n, m, i, j, pre, ans; scanf("%d",&n); scanf("%d",&m); for(int i=1; i<=n; i++){ scanf("%d",&a[i]); } for(int i=0; i<m; i++){ scanf("%d",&b[i]); } sort(a+1, a+n+1); ans=0; for(i=0; i<(1<<m); i++){ for(j=0; j<m; j++){ if((1<<j)&i){ pre=(1<<j)^i; // cout<<i<<" "<<pre<<endl; if(a[dp[pre].ff+1]==dp[pre].ss+b[j] && dp[pre].ff+1<=n){ dp[i]=max(dp[i], mp(dp[pre].ff+1, 0)); if(dp[i].ff==n){ ans++; } } else{ dp[i]=max(dp[i], mp(dp[pre].ff, dp[pre].ss+b[j])); // cout<<" "<<dp[i].ff<<" "<<dp[i].ss<<endl; } } } } if(ans) printf("YES\n"); else printf("NO\n"); return 0; }

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

bank.cpp: In function 'int main()':
bank.cpp:17:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
bank.cpp:18:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |  scanf("%d",&m);
      |  ~~~~~^~~~~~~~~
bank.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   scanf("%d",&a[i]);
      |   ~~~~~^~~~~~~~~~~~
bank.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |   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...