#20406: 卡在WA(line7)似乎少了空行,下面加\n又OLE,求解@.@


71xi46@ms.mingdao.edu.tw (questionm)

學校 : 臺中市私立明道高級中學
編號 : 102270
來源 : [106.1.27.35]
最後登入時間 :
2020-01-24 22:26:33
c094. 00661 - Blowing Fuses -- UVa661 | From: [106.1.27.35] | 發表日期 : 2020-01-16 21:42

#include <iostream>
#include <algorithm>
using namespace std;

int main(void) {
int n,m,c,max,sum,sq,a[21],b[21],z;
bool tf=1;
sq=1;
while(cin>>n>>m>>c&&n!=0)
{

max=0;
sum=0;
tf=1;
for(int i=1;i<=n;i++)
cin>>a[i];
for(int i=1;i<=n;i++)
b[i]=0;
for(int i=1;i<=m;i++)
{
cin>>z;
if(b[z]==0)
{
b[z]++;
sum+=a[z];
if(sum>c)
tf=0;
if(sum>max)
max=sum;
}else
{
b[z]--;
sum-=a[z];
}
}
cout<<"Sequence "<<sq<<endl;
sq++;
if(tf==0)
{
cout<<"Fuse was blown.\n"<<endl;
continue;
}
cout<<"Fuse was not blown.\nMaximal power consumption was "<<max<<" amperes.(\n)(似乎是這裡的問題(?))"<<endl;
}
return 0;
}

 
ZeroJudge Forum