#include<stdio.h>
#include<string.h>
#define M 21
int State[M],Conjump[M],Opration[M];
int main()
{
int m,n,c,opt,curr,max,i,k=1;
//freopen("in.txt","r",stdin);
while(scanf("%d%d%d",&n,&m,&c)&&(n|m|c))
{
memset(State,0,sizeof(State));
for(i=1;i<=n;i++)
scanf("%d",&Conjump[i]);
max = curr = 0;
for(i=0;i<m;i++)
{
scanf("%d",&opt);
if(max==-1)continue;
State[opt] = 1 - State[opt];
if(State[opt])
curr += Conjump[opt];
else
curr -= Conjump[opt];
if(curr>c)
max = -1;
else if(curr>max)
max = curr;
}
if(max==-1)
printf("Sequence %d\nFuse was blown.\n\n",k++);
else
printf("Sequence %d\nFuse was not blown.\nMaximal power consumption was %d amperes.\n\n",k++,max);
}
return 0;
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.