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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
#include <iostream> #include <cstdio> #include <cstring> #include <string> using namespace std; int capacity[21]; bool isTurnOn[21]; int main() { int n,m,c; int MX=0; int device; int kase=1; bool IsFUSE; long long total; while(scanf("%d%d%d",&n,&m,&c)) { if(n+m+c==0) break; //memset(capacity,0,sizeof(capacity)); //memset(isTurnOn,0,sizeof(isTurnOn)); IsFUSE=0; for(int i=1;i<=n;i++) { scanf("%d",&capacity[i]); isTurnOn[i]=0; } total=0; MX=0; for(int i=1;i<=m;i++) { scanf("%d",&device); if(IsFUSE) continue; if(isTurnOn[device]==0) { isTurnOn[device]=1; total+=capacity[device]; } else if(isTurnOn[device]==1) { isTurnOn[device]=0; total-=capacity[device]; } if(total>c) { IsFUSE=1; } if(total>MX) MX=total; } printf("Sequence %d\n",kase++); if(IsFUSE) printf("Fuse was blown.\n"); else { printf("Fuse was not blown.\n"); printf("Maximal power consumption was %d amperes.\n",MX); } printf("\n"); } return 0; } |