661 - Blowing Fuses

All about problems in Volume 6. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

gms
New poster
Posts: 1
Joined: Sat Jun 23, 2007 5:04 pm
Location: Valladolid,Spain

661 WA:need sample input output(du_cse)

Post by gms » Sun Jun 24, 2007 11:56 am

Thnks Jan

Code: Select all


GOT ACC

Last edited by gms on Sun Oct 12, 2008 9:00 am, edited 2 times in total.

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Sun Jun 24, 2007 3:02 pm

Increase the size of the array 'search'. Use 'search[1001]'. As far as I can remember, 'm' (you are using as 'b') can be bigger than 100.

Hope it helps.
Ami ekhono shopno dekhi...
HomePage

sazzadcsedu
Experienced poster
Posts: 136
Joined: Sat Nov 29, 2008 8:01 am
Location: narayangong,bangladesh.
Contact:

661 - Blowing Fuses

Post by sazzadcsedu » Fri Jan 30, 2009 11:30 pm

WHY RTE??
SOMEONE HELP.

Code: Select all

    #include<stdio.h>


                       int main()



				 { 
						 int i,m,n,c,con[22],op,stat[22];
						 int totcon,max,flag,seq=1;

						 while(scanf("%d %d %d",&n,&m,&c)==3)

						 {    
                       if(n==0 && m==0 && c==0)
								  break;

                               
                              for(i=0;i<n;i++)


							        { 
								  stat[i]=0;
                           }

							 for(i=0;i<n;i++)

							 {  
								 scanf("%d",&con[i]);


							 } 

							 totcon=0;
							 max=0;
							 flag=1;

							 for(i=0;i<m;i++)

							 { 
								 scanf("%d",&op);
                                  
								  if(stat[op-1]==0)
								  {
									  totcon=totcon+con[op-1];
								      stat[op-1]=1;
									  
								  }

								  else
								  { 
									  totcon=totcon-con[op-1];
                                       stat[op-1]=0;

								  }

								  if(totcon>c)
								  {
                              flag=0;
								     break;
								  }

                            if(max<totcon)
									max=totcon;


							 }
							  
                           printf("Sequence %d\n",seq);

							   if(flag==0)
								printf("Fuse was blown.\n\n");

							   else
							   { printf("Fuse was not blown.\n");
							       printf("Maximal power consumption was %d amperes.\n\n",max);
							   }

							   seq++;
						 }

						 return 0;
                                
                              

					   }
Life is more complicated than algorithm.
http://felix-halim.net/uva/hunting.php?id=32359
For Hints: http://salimsazzad.wordpress.com

newkid
Learning poster
Posts: 73
Joined: Fri Dec 12, 2008 3:06 am

Re: 661 - Blowing Fuses

Post by newkid » Sat Jan 31, 2009 12:21 am

Hi,
You are not taking all the input. you are breaking the for loop.. remove the break and try doing this..

[quote="sazzadcsedu"]WHY RTE??
SOMEONE HELP.

Code: Select all

 ...................
   for(i=0;i<m;i++) {
      scanf("%d",&op);

      if (flag == 0)
        continue;
      .............
      .............

      if(totcon>c) {
        flag=0;
        //break;  remove this..
      }
    ...............
hmm..

shantanu18
New poster
Posts: 22
Joined: Tue Jul 20, 2010 9:55 pm

Re: 661 - Blowing Fuses

Post by shantanu18 » Tue Jul 20, 2010 10:00 pm

WA!!! please help!

Code: Select all

#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
struct Amp
{
	bool status;
	int wight;
};
int main()
{
	//freopen("input.txt","r",stdin);
	int n,m,c,ca=1,total,s[100],cl=0;
	struct Amp arr[100];

	while(scanf("%d%d%d",&n,&m,&c)==3 && n && m && c)
	{
		if(ca>1) printf("\n");
		memset(arr,0,sizeof(arr));
		total=0;
		int max=-100;
		bool flag=false;
		max=-1;cl=0;
		for(int i=0;i<n;i++)
		{
			scanf("%d",&arr[i].wight);
			arr[i].status=false;
		}
		for(int i=0;i<m;i++)
			scanf("%d",&s[i]);
		for(int i=0;i<m;i++)
		{
			if(!arr[s[i]-1].status)
			{
				arr[s[i]-1].status=true;
				total+=arr[s[i]-1].wight;
			}
			else
			{
				arr[s[i]-1].status=false;
				total-=arr[s[i]-1].wight;
			}
			if(total>c)
			{
				flag=true;break;
			}
			if(max<total) max=total;
		}
		printf("Sequence %d\n",ca++);	
		if(flag)
			printf("Fuse was blown.\n");
		else
		{
			printf("Fuse was not blown.\nMaximal power consumption was %d amperes.\n",max);

		}

	}
	return 0;
}


mostafa_angel
New poster
Posts: 23
Joined: Sun Oct 04, 2009 12:03 pm

Re: 661 - Blowing Fuses

Post by mostafa_angel » Mon May 16, 2011 1:55 am

I Don't Know I got WA in this easy problem ... :(
please Help...

Code: Select all

AC

kp25
New poster
Posts: 2
Joined: Sat Apr 28, 2012 7:16 pm

Re: 661 - Blowing Fuses

Post by kp25 » Sat Apr 28, 2012 7:22 pm

What is the mistake in my code..?
all the time it is reporting runtime error..??
here my code,

#include<stdio.h>
#define max(A,B) ((A>B)?A:B)
int main()
{
int n,m,c,t=1;
int current[22],op[22];
while(1)
{
scanf("%d %d %d",&n,&m,&c);
if(n==0&&m==0&&c==0)
break;
register i;
int flag[22]={0};
for(i=1;i<=n;i++)
scanf("%d",&current);
for(i=1;i<=m;i++)
scanf("%d",&op);
int temp=0,maxima=0,pole,temp2;
for(i=1;i<=m;i++)
{
temp2=op;
pole=0;
if(flag[temp2]==0)
{
temp=temp+current[temp2];
flag[temp2]=1;
}
else
{
temp=temp-current[temp2];
flag[temp2]=0;
}
maxima=max(maxima,temp);
if(temp>c)
{
printf("Sequence %d\n",t);
printf("Fuse was blown.\n");
break;
}
else
pole=1;
}
if(pole==1)
{
printf("Sequence %d\n",t);
printf("Fuse was not blown.\n");
printf("Maximal power consumption was %d amperes.\n",maxima);
}
t++;
printf("\n");
}
return 0;
}

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 661 - Blowing Fuses

Post by brianfry713 » Mon Apr 30, 2012 10:37 pm

m might be bigger than 21.
Check input and AC output for thousands of problems on uDebug!

stride
New poster
Posts: 2
Joined: Thu Aug 16, 2012 10:31 am

Re: 661 - Blowing Fuses

Post by stride » Thu Aug 16, 2012 10:49 am

help kept getting WA i dunno what to fix anymore :'(

[Code removed for AC, ty Brianfry713 for the debugging]
Last edited by stride on Fri Aug 17, 2012 5:44 pm, edited 1 time in total.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 661 - Blowing Fuses

Post by brianfry713 » Thu Aug 16, 2012 11:39 pm

Output a blank line after each test case.
Check input and AC output for thousands of problems on uDebug!

Elsterrier
New poster
Posts: 3
Joined: Fri Jan 11, 2013 2:58 pm

Re: 661 - Blowing Fuses

Post by Elsterrier » Fri Jan 11, 2013 3:05 pm

can anyone help me
i got WA but i don't know what's wrong with my code

Code: Select all

got AC

catalan
New poster
Posts: 4
Joined: Sun Jun 16, 2013 8:25 pm

661 - Blowing Fuses - Getting Submission Error

Post by catalan » Sun Jun 16, 2013 8:35 pm

I am getting SE for this problem. It seems to run correctly. But the judge runs it for sometime and issues a SE. Many people have got the problem AC. Please help.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 661 - Blowing Fuses - Getting Submission Error

Post by brianfry713 » Mon Jun 17, 2013 11:28 pm

If you're getting a submission error, then try a different problem. If it is WA or TLE or RE then your code might have a different issue.
Check input and AC output for thousands of problems on uDebug!

cyberdragon
New poster
Posts: 20
Joined: Fri Aug 30, 2013 5:42 am

661 - Blowing Fuses

Post by cyberdragon » Tue Sep 24, 2013 1:32 am

http://ideone.com/1xjOFv

Why I'm getting Runtime Error ?

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 661 - Blowing Fuses

Post by brianfry713 » Tue Sep 24, 2013 10:50 pm

You need to keep reading the input after a fuse blows.
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 6 (600-699)”