Page 4 of 6

Why wrong answer 362 18,000 seconds remaining

Posted: Wed Jul 05, 2006 11:55 am
by Mushfiqur Rahman
I could'nt find out the the logical or other types of error. I checked it for many input. For those it's 100% ok! But still it's getting WA..!
But Why?

If anybody can give the answer i will be very grateful to him.

Code: Select all

Removed after got AC

Posted: Wed Jul 05, 2006 8:14 pm
by Kallol
well, I think, the problem is in the type casting.
u have casted "float" in one place in ur code...try with making it double.
and instead of dividing by 5 , divide by 5.0.
hope this will help u
u may visit
and i thing there are more threads for this problem here . U may post in those thread ,too.

Thanks for Kallol

Posted: Fri Jul 28, 2006 9:36 pm
by Mushfiqur Rahman
Dear Kallol,
Thanks to you for your great help. Now I got AC. When I changed my all variable into long int instead of doubel and then casting in double then it got AC. I sow your post after got AC. Then I checked my code with your tips but it got WA. So one should follow this suggestion that try to use all variable in long type and then cast it into double.

I am grateful to you.

362 P.E.

Posted: Sun Jun 24, 2007 4:12 pm
by N@$!M
Here is My Code For Which I Have got P.E.

Code: Select all


int main(void)
    double tb,takenTotal,takenPrev5,take;
    long t,dataset = 1;
    bool tag = false;

        if(tag == false) tag = true;
        else printf("\n");
    return 0;
.........CODE REMOVED :wink:

Posted: Mon Jun 25, 2007 10:48 am
by Jan
There should be a blank line after every case. But your code doesn't print a blank line after the last case.

Hope it helps.

362 - WA please help me.

Posted: Mon Nov 26, 2007 3:46 pm
by alamgir kabir
I have got it accepted but very much surprised!!!!!!!!!
Ii's a very much technical and fraction error.
so everyone be careful to handle fraction errors.
I type cast the double into long
Thanks all

I have almost 40 submissions and still WA!!!

Posted: Mon Dec 24, 2007 10:06 pm
by ligregni
Hi, I'm desesperate, I need help!,

I have revewed all the output sentences, I tried all the cases I've found and they are OK!,

I also tried printing after each case (including last one) "\n\n", or printing after each case (including last) "\n", but printing after each case (except the last) "\n" (all of this is printing two \n after all cases exept the last, where I only print one) or printing "\n\n" after all cases except last one (who is "empty" after him),

I tried printing all of this combinations after scanning the # of bytes or before that (I need your help giving me the answer of the \n issue, it will help a lot),

I am almost sure the Math issue is correct (for avoid ceil(), I made the same calculus whith a double and an integer, if they are not the same, I print the integer (long actually) plus 1),

I remember you I've tried with all cases I've found and some extrem I thinked (for example, 10000 bytes, and in the first 5 seconds just one byte has been transferred, and after that one stalled, and then all the bytes less one tranfers, and calculus the time remaining),

I also checked all the ':' and that stuff,

I'm getting crazy with this problem,

I know it's OK, but UVa doesn't think the same, and I'm pretty sure it is by any little thing, but I don't know, what, so, here is my code:

Code: Select all

/* 18,000 Seconds Remaining */

#include <stdio.h>

int main ()
/* FILE *in = freopen ("", "r", stdin); /**/

	long b=0, B=0, c=0;

	scanf("%i", &b);

	while (b!=0)

/*		if (c!=1)

		long sec=0, time[5];

		printf("Output for data set %d, %d bytes:\n", c, b);


		while (B<b)
			scanf("%i", &time[sec%5]);

			B += time[sec%5];


			if (sec%5==0)
				long suma=0, x=0;

				double t=0.0;

					suma += time[x-1];

				t = suma/5.0;

				double d=0;

				if (t!=0)
					x = (b-B)/t;

					d = (b-B)/t;

					if (x!=d)

				printf("   Time remaining: ");

				if (t==0)
					printf("%i seconds\n", x);

		printf("Total time: %i seconds\n", sec);

		scanf("%i", &b);

		if (b!=0)


	return 0;

This version of my code is the one who prints \n after all cases and another \n after all cases except last one.

I get WA at 0.190 secs aprox, so I know it could be almost at the end.

aprox 5 of my WA was because I forgot to comment the FILE *in line, but I have trained myself to avoid that.


Sergio Ligregni

Re: 362 - WA many times but works for evry cases in forum...

Posted: Fri Apr 18, 2008 11:24 pm
by kbr_iut
AC,,,code deleted..
Its too pathetic that,,,when I used ceil(double vale) i got WA
when i used ceil(double value+1e-7)i got WA
when I used (int)(double value+.9999999)i got AC....but why?
so think everyone how much one should b careful calculating floating point numbers!

Re: 362 why WA???

Posted: Mon Apr 28, 2008 8:03 am
by mukit
To Morning :
change the line :

Code: Select all

aver /= 5;

Code: Select all

aver /= 5.0;
And you should have print the output lines into proper format(spaces).
Like :

Code: Select all

cout << " Time remaining: " << ceiling((size - sum) / aver) << " seconds" << endl; 
would be

Code: Select all

cout << "   Time remaining: " << ceiling((size - sum) / aver) << " seconds" << endl;
Hope this will work.


Re: 362 why WA???

Posted: Mon Apr 28, 2008 9:33 am
by Obaida
To "Morning" you should use "return 0;" in "int main" function.
Else you can use void main.

Re: 362 - IO tricky samples

Posted: Fri May 30, 2008 10:57 am
by fR0D
can somebody please point out why am i getting WA?

Code: Select all

Got AC.
Changed the line
printf("   Time remaining: %.0f seconds\n",ceil(remainingBytes/((float)transferedBytes/5.0)));
printf("   Time remaining: %.0f seconds\n",ceil(remainingBytes/((double)transferedBytes*0.2)));
and GOT AC.
i tried all test cases on forum and got expected answer still WA.

362 TLE... Please help me

Posted: Wed Sep 03, 2008 8:16 am
by wam3483
OMFG ok, I've been working at this for 4 hours. I've joined this forum just because it seems like people round here know thier stuff (for the most part :].) I'm a java coder. I feel I'm pretty knowledgable, but Problem 362: 18,000 seconds left has just got me stumped.

Here's my code:

Code: Select all

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(;
		int index = 0;
		int totalBytes = scan.nextInt();
		while (totalBytes > 0) {
			System.out.println("Output for data set " + (++index) + ", "
					+ totalBytes + " bytes:");

			int bytesRead = 0, seconds = 0, count = 0;
			double transWindow = 0;
			//while more bytes to read
			while (totalBytes > bytesRead) {
				int temp = scan.nextInt();
				transWindow += temp;
				bytesRead += temp;
				if (count == 5) {
					if (transWindow > 0) {
						System.out.println("   Time remaining: "
								+ (int) Math.ceil((totalBytes - bytesRead)
										/ (transWindow / 5.0)) + " seconds");
					} else {
						System.out.println("   Time remaining: stalled");
					count =0;
			System.out.println("Total time: " + seconds + " seconds\n");
			totalBytes = scan.nextInt();
Like I said, I get Time Limit Exceeded inside the 2nd "while" loop. I don't know why. I know it isn't infinte... I've tested a huge number of test cases against this code and I honestly can't find a thing wrong with it.

Please help me...

Re: 362 TLE... Please help me

Posted: Sun Sep 07, 2008 10:49 am
by Jan
Use existing threads.

Re: 362 - IO tricky samples

Posted: Sat Sep 20, 2008 12:39 am
by kbr_iut
u can use that technic posted immediate before u.
double d contains ur result. u need to round (to ceil)
just use this
print tem;

hope it will help.

Re: 362 why WA man!!!!!!!!

Posted: Sat Nov 22, 2008 8:19 pm
by abid_iut
why WA it is giving every output right
here is the code:

Code: Select all


int main()
	long size,time,count,sum,n=1,byte,line=0;
	double aver,remainsecond;
	while(scanf("%ld",&size)==1&& size){
	printf("Output for data set %ld, %ld bytes:\n",n++,size);
			if(aver==0)printf("   Time remaining: stalled\n");
			else {
				printf("   Time remaining: %.0lf seconds\n",ceil(remainsecond));
	printf("Total time: %ld seconds\n",time);
	return 0;