661 - Blowing Fuses

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

Moderator: Board moderators

661 WA:need sample input output(du_cse)

Postby 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.
gms
New poster
 
Posts: 1
Joined: Sat Jun 23, 2007 5:04 pm
Location: Valladolid,Spain

Postby 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
Jan
Guru
 
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh

661 - Blowing Fuses

Postby 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;
                               
                             

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

Re: 661 - Blowing Fuses

Postby 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..
newkid
Learning poster
 
Posts: 73
Joined: Fri Dec 12, 2008 3:06 am

Re: 661 - Blowing Fuses

Postby 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;
}

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

Re: 661 - Blowing Fuses

Postby 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
mostafa_angel
New poster
 
Posts: 23
Joined: Sun Oct 04, 2009 12:03 pm

Re: 661 - Blowing Fuses

Postby 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[i]);
for(i=1;i<=m;i++)
scanf("%d",&op[i]);
int temp=0,maxima=0,pole,temp2;
for(i=1;i<=m;i++)
{
temp2=op[i];
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;
}
kp25
New poster
 
Posts: 1
Joined: Sat Apr 28, 2012 7:16 pm

Re: 661 - Blowing Fuses

Postby brianfry713 » Mon Apr 30, 2012 10:37 pm

m might be bigger than 21.
brianfry713
Guru
 
Posts: 1742
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 661 - Blowing Fuses

Postby 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.
stride
New poster
 
Posts: 2
Joined: Thu Aug 16, 2012 10:31 am

Re: 661 - Blowing Fuses

Postby brianfry713 » Thu Aug 16, 2012 11:39 pm

Output a blank line after each test case.
brianfry713
Guru
 
Posts: 1742
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 661 - Blowing Fuses

Postby 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
Elsterrier
New poster
 
Posts: 3
Joined: Fri Jan 11, 2013 2:58 pm

Previous

Return to Volume VI

Who is online

Users browsing this forum: No registered users and 0 guests