Submission #1297410

#TimeUsernameProblemLanguageResultExecution timeMemory
1297410baotoan655Bank (IZhO14_bank)C++20
100 / 100
144 ms4500 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; }

Compilation message (stderr)

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