| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
最头疼的WA,感觉无从下手了,大牛帮忙看看!#include <iostream>
using namespace std;
int main()
{
int n,m,c,i,anpei[21],operation[1000],count = 0;
bool on[20],blown = 0;
while(cin >> n >> m >> c && n != 0 && m != 0 && c != 0){
memset(anpei,0,sizeof(anpei));
memset(on,0,sizeof(on));
cout << "Sequence " << ++count << endl;
for(i = 1;i <= n;i++)
cin >> anpei[i];
for(i = 0;i < m;i++)
cin >> operation[i];
int current = 0,maxap = 0;
for(i = 0;i < m;i++){
if(on[operation[i]] == 0){
on[operation[i]] = 1;
current += anpei[operation[i]];
if(current > maxap)
maxap = current;
}
else{
on[operation[i]] = 0;
current -= anpei[operation[i]];
}
if(current > c){
blown = 1;
cout << "Fuse was blown.\n";
break;
}
}
if(i == m && blown == 0){
cout << "Fuse was not blown.\n";
cout << "Maximal power consumption was " << maxap << " amperes.\n";
}
cout << endl;
blown = 0;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator