1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
int () { bool state[21]; int cost[21]; int n, m, c, Case = 1; while (scanf("%d%d%d", &n, &m, &c) && (n || m || c)) { int i, k, now = 0, max = 0; for (i = 1; i <= n; i++) state[i] = false; for (i = 1; i <= n; i++) scanf("%d", &cost[i]);
for (i = 0; i < m; i++) { scanf("%d", &k);
if (max != -1) { state[k] = !state[k]; if (state[k]) now += cost[k]; else now -= cost[k];
if (now <= c) { if (now > max) max = now; } else max = -1; } }
printf("Sequence %dn", Case++); if (max == -1) puts("Fuse was blown.n"); else { puts("Fuse was not blown."); printf("Maximal power consumption was %d amperes.nn", max); } }
return 0; }
|
近期评论