Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

最头疼的WA,感觉无从下手了,大牛帮忙看看!

Posted by 771385494 at 2011-11-22 20:06:00 on Problem 1484
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator