제출 #580543

#제출 시각아이디문제언어결과실행 시간메모리
580543yutabi은행 (IZhO14_bank)C++14
44 / 100
1092 ms468 KiB
#include <bits/stdc++.h> using namespace std; #define pb push_back typedef long long ll; typedef pair <ll,ll> ii; int n; int m; vector <int> s; vector <int> x; bool DP2[1001][1001]; int main() { scanf("%d %d",&n,&m); if(n==1){ for(int i=0;i<n;i++) { int a; scanf(" %d",&a); s.pb(a); } for(int i=0;i<m;i++) { int a; scanf(" %d",&a); x.pb(a); } DP2[0][0]=1; for(int i=0;i<m;i++) { for(int j=0;j<1001;j++) { if(x[i]+j<1001 && DP2[i][j]==1) { DP2[i+1][x[i]+j]=1; } if(DP2[i][j]) { DP2[i+1][j]=1; } } } if(DP2[m][s[0]]) { printf("YES"); } else { printf("NO"); }} else{ bool table[n+1][1<<m]; bool DP[n+1][1<<m]; for(int i=0;i<1<<m;i++) { DP[0][i]=1; table[0][i]=0; } for(int j=1;j<n+1;j++) { for(int i=0;i<1<<m;i++) { DP[j][i]=0; table[j][i]=0; } } for(int i=0;i<n;i++) { int a; scanf(" %d",&a); s.pb(a); } for(int i=0;i<m;i++) { int a; scanf(" %d",&a); x.pb(a); } for(int i=0;i<1<<m;i++) { int a=i; int sum=0; for(int j=0;j<m;j++,a/=2) { if(a%2) { sum+=x[j]; } } for(int j=0;j<n;j++) { if(s[j]==sum) { table[j][i]=1; } } } for(int i=0;i<n;i++) { for(int j=0;j<1<<m;j++) { for(int k=0;k<1<<m;k++) { if(((j&k)==0) && DP[i][j] && table[i][k]) { DP[i+1][j|k]=1; } } } } if(DP[n][(1<<m)-1]==1) { printf("YES"); } else { printf("NO"); }} }

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

bank.cpp: In function 'int main()':
bank.cpp:21:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     scanf("%d %d",&n,&m);
      |     ~~~~~^~~~~~~~~~~~~~~
bank.cpp:29:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         scanf(" %d",&a);
      |         ~~~~~^~~~~~~~~~
bank.cpp:38:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |         scanf(" %d",&a);
      |         ~~~~~^~~~~~~~~~
bank.cpp:98:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   98 |         scanf(" %d",&a);
      |         ~~~~~^~~~~~~~~~
bank.cpp:107:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  107 |         scanf(" %d",&a);
      |         ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...