#13165: ERROR???


10530826 (Starry Knight)

學校 : 臺北市立成功高級中學
編號 : 62083
來源 : [114.198.167.25]
最後登入時間 :
2020-11-14 10:15:59
c094. 00661 - Blowing Fuses -- UVa661 | From: [49.159.135.82] | 發表日期 : 2017-12-24 12:18

#0: 100% WA (line:3)

您的答案為: Seque ...略

正確答案為:

 

#include<iostream>
using namespace std;
int main()
{
int n,m,c,I[20],D[20],k,t=1;
while(cin>>n>>m>>c)
{
int sum=0,max=0;
bool blow=false;
if(n==0&&m==0&&c==0)
break;
for(int i=0;i<n;i++)
{
cin>>I[i];
D[i]=-1;
}
for(int i=0;i<m;i++)
{
cin>>k;
D[k-1]*=-1;
sum+=I[k-1]*D[k-1];
if(sum>c)
blow=true;
else if(sum>max)
max=sum;
}
cout<<"Sequence "<<t<<endl;
t++;
if(blow)
cout<<"Fuse was blown.\n";
else
{
cout<<"Fuse was not blown.\n";
cout<<"Maximal power consumption was "<<max<<" amperes.\n";
}
}
return 0;
}

 
ZeroJudge Forum