#include <iostream>
#include <memory.h>
#include <cstdio>
using namespace std;
const int maxn = 21;
int w[maxn], s[maxn],C, N, M;
int main(){
int cas = 1;
while(scanf("%d%d%d", &N, &M, &C)){
if(!N && !M && !C)break;
memset(s, 0, sizeof(s));
for(int i = 1; i <= N; ++i){
scanf("%d", &w[i]);
}
int curPow = 0, f = 0 , maxPow = 0;
for(int i = 0; i < M; ++i){
int device;
scanf("%d", &device);
if(s[device]){
curPow -= w[device];
}else{
curPow += w[device];
}
s[device] = !s[device];
if(curPow > C){
f = 1;
}
if(curPow > maxPow){
maxPow = curPow;
}
}
printf("Sequence %d\n", cas++);
if(f){
printf("Fuse was blown.\n");
}else{
printf("Fuse was not blown.\n");
printf("Maximal power consumption was %d amperes.\n", maxPow);
}
printf("\n");
}
return 0;
}
ZOJ 1195 Blowing Fuses
最新推荐文章于 2019-01-30 21:49:32 发布