#include<bits/stdc++.h>
using namespace std;
main()
{
long long a,b,c,cs=1;
while(cin>>a>>b>>c)
{
long long a1,k,visit[100]={0},ans=0,mp[1000]={0},i,sum=0;
if(a==0&&b==0&&c==0)
break;
else
{
printf("Sequence %lld\n",cs);
for(i=1;i<=a;i++)
{
cin>>k;
mp[i]=k;
}
for(i=1;i<=b;i++)
{
cin>>a1;
if(visit[a1]==0)
{
sum=sum+mp[a1];
visit[a1]=1;
}
else if(visit[a1]==1)
{
sum-=mp[a1];
visit[a1]=0;
}
ans=max(ans,sum);
}
if(ans>c)
{
printf("Fuse was blown.\n");
}
else
{
printf("Fuse was not blown.\n");
printf("Maximal power consumption was %lld amperes.\n",ans);
}
cout<<endl;
}
cs++;
}
}
using namespace std;
main()
{
long long a,b,c,cs=1;
while(cin>>a>>b>>c)
{
long long a1,k,visit[100]={0},ans=0,mp[1000]={0},i,sum=0;
if(a==0&&b==0&&c==0)
break;
else
{
printf("Sequence %lld\n",cs);
for(i=1;i<=a;i++)
{
cin>>k;
mp[i]=k;
}
for(i=1;i<=b;i++)
{
cin>>a1;
if(visit[a1]==0)
{
sum=sum+mp[a1];
visit[a1]=1;
}
else if(visit[a1]==1)
{
sum-=mp[a1];
visit[a1]=0;
}
ans=max(ans,sum);
}
if(ans>c)
{
printf("Fuse was blown.\n");
}
else
{
printf("Fuse was not blown.\n");
printf("Maximal power consumption was %lld amperes.\n",ans);
}
cout<<endl;
}
cs++;
}
}
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন