제출 #13508

#제출 시각아이디문제언어결과실행 시간메모리
13508woqja125은행 (IZhO14_bank)C++98
100 / 100
195 ms4800 KiB
#include<stdio.h> #include<set> const int MAX = 20; const int PMAX = 1<<MAX; int a[MAX], b[MAX]; int s[MAX]; int cnt[PMAX]; int max(int a, int b){return a>b?a:b;} int main() { int n, m; int i, j; scanf("%d%d", &n, &m); for(i=0; i<n; i++) { scanf("%d", a+i); s[i] += a[i]; s[i+1] += s[i]; } for(i=0; i<m; i++)scanf("%d", b+i); for(i=0; i<(1<<m); i++) { int x = i; int sum = 0; for(j=0; j<m; j++) if((x>>j)&1) sum += b[j]; int type = -1; for(j=0; j<n; j++) if(s[j] == sum) type = j; if(type == 0) cnt[i] = 1; else if(type == -1) { for(j=0; j<m; j++) if((x>>j)&1) cnt[i] = max(cnt[i], cnt[i-(1<<j)]); } else { for(j=0; j<m; j++) if(((x>>j)&1) && cnt[i-(1<<j)] == type) cnt[i] = type+1; } if(cnt[i] == n) { printf("YES"); return 0; } } printf("NO"); return 0; }

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

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