Time limit exceeded

General topic about Valladolid Online Judge

Moderator: Board moderators

Time limit exceeded

Postby Eng_XD » Mon Aug 10, 2009 5:43 pm

I tried to submit my source code of the problem 10300 - Ecological Premium and i got the messenge Time limit exceeded. The run time was 3.00 seconds but the Time limited is 1.00 second, i`ve tried to simplify the algorithm but i failed. I don`t know what i can do. pls Help me.
Source Code:

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{

int n, f, i, j, sum, space, animals, C;

while (n!=EOF){

scanf ("%d", &n);
for( i=0; i<n; i++){
scanf("%d", &f);
sum=0;
for (j=0; j<f; j++){
scanf("%d%d%d", &space, &animals, &C);
sum+=space*C;
}

printf("%d\n", sum);

}
}


return 0;
}
Eng_XD
New poster
 
Posts: 1
Joined: Mon Aug 10, 2009 5:33 pm

Re: Time limit exceeded

Postby sazzadcsedu » Tue Aug 11, 2009 9:31 pm

Several things to note:
Post title should contain Problem no like(10300-ecological premium) not TLE,WA,CE etc.
so remember this.And dont forget to place your code inside Quote tag;


You have problem in input taking. you program continue taking input,never ends.so TLE occurs.
So take input such a way-
Code: Select all
int ncase;   //variable  contain no. of cases;
scanf("%d",&ncase);
 while(ncase>0)
{
   
      code.................


   
 
  ncase--;
}


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


Return to General

Who is online

Users browsing this forum: No registered users and 0 guests