Submission #767283

#TimeUsernameProblemLanguageResultExecution timeMemory
767283rainboyBank (IZhO14_bank)C11
100 / 100
88 ms8476 KiB
#include <stdio.h> #define N 20 #define M 20 int max(int a, int b) { return a > b ? a : b; } int main() { static int aa[N], ss[1 << M], dp[1 << M]; int n, m, i, j, b; scanf("%d%d", &n, &m); for (i = 0; i < n; i++) scanf("%d", &aa[i]); for (i = 1; i < n; i++) aa[i] += aa[i - 1]; for (j = 0; j < m; j++) scanf("%d", &ss[1 << j]); for (b = 1; b < 1 << m; b++) ss[b] = ss[b & b - 1] + ss[b & -b]; for (b = 1; b < 1 << m; b++) { for (j = 0; j < m; j++) if ((b & 1 << j) != 0) dp[b] = max(dp[b], dp[b ^ 1 << j]); for (i = 0; i < n; i++) if (ss[b] == aa[i]) { dp[b]++; break; } } printf(dp[(1 << m) - 1] == n ? "YES\n" : "NO\n"); return 0; }

Compilation message (stderr)

bank.c: In function 'main':
bank.c:20:20: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   20 |   ss[b] = ss[b & b - 1] + ss[b & -b];
      |                  ~~^~~
bank.c:12:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  scanf("%d%d", &n, &m);
      |  ^~~~~~~~~~~~~~~~~~~~~
bank.c:14:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |   scanf("%d", &aa[i]);
      |   ^~~~~~~~~~~~~~~~~~~
bank.c:18:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |   scanf("%d", &ss[1 << j]);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...