给出若干个用电器的功率,还有若干操作
问一系列操作后会不会使得中间某些时候超过功率上限,
求最大功率
2Y PE了一次因为是每个case后面都有空行
#include <bits/stdc++.h>
using namespace std;
int n,m,c;
void Gao()
{
int a[100]={0};
bool f[100]={0};
int ans=0,tem=0;
for(int i=0;i<n;i++) cin>>a[i+1];
for(int i=0;i<m;i++)
{
int x;
cin>>x;
if (f[x])
{
f[x]=false;
tem-=a[x];
}
else
{
f[x]=true;
tem+=a[x];
ans=max(ans,tem);
}
}
if (ans>c)
cout<<"Fuse was blown."<<endl;
else
{
cout<<"Fuse was not blown." <<endl;
printf("Maximal power consumption was %d amperes.\n",ans);
}
}
int main()
{
bool fst=false;
int inc=1;
// freopen("a.in","r",stdin);
while (cin>>n>>m>>c &&(n|m|c))
{
cout<<"Sequence "<<(inc++)<<endl;
fst=true;
Gao();
cout<<endl;
}
return 0;
}