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

请大牛给看看。

Posted by willard at 2007-11-19 13:10:15 on Problem 1484
In Reply To:没有发现这样的情况 Posted by:frkstyc at 2007-11-19 12:23:13
#include <stdio.h>

void main()
{
	int dev[21], c, max, i, n, m, op, tc=0, now;
	scanf("%d%d%d", &n, &m, &c);
	while(n != 0 && m != 0 && c != 0)
	{
		bool bk = false;
		tc++;
		int on[21] = {0};
		max = 0;
		now = 0;
		if(n >= 21 || n < 0) // 如果去掉这一句,就是RE了。含这一句,就是WA。这是怎么回事呢?
			return;
		for(i = 0; i < n; i++)
			scanf("%d", &dev[i]);
		for(i = 0; i < m; i++)
		{
			scanf("%d", &op);
			--op;
			if(op < 0 || op >= n)
				continue;
			if(on[op] == 0)
			{
				on[op] = 1;
				now += dev[op];
				if(now > c)
				{
					bk = true;
					break;
				}
				if(now > max)
					max = now;
			}else
			{
				on[op] = 0;
				now -= dev[op];
			}
		}
		printf("Sequence %d\n", tc);
		if(bk)
			printf("Fuse was blown.\n\n");
		else
			printf("Fuse was not blown.\nMaximal power consumption was %d amperes.\n\n", max);
		scanf("%d%d%d", &n, &m, &c);
	}
}


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