ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1061. Buffer Manager

What is TEST#2
Posted by Bunyodbek Bobodjanov (TATU UF) 6 Nov 2009 14:27
Give me some tests.

This My Code:

 int min =Integer.MAX_VALUE;
 while((x = in.read())!=-1)
 {
 if(x!=10 && x!=13){
 um++;
 if((char)x!='*')    {
 k = Integer.parseInt((char)x+"");
 a[++count] = k;
 }
 if((char)x=='*'){
 for (int i = 1; i <= count-m+1 ; i++) {
 sum = 0;
    for (int j = i; j <= i+m-1 ; j++) {
    sum = sum + a[j];
    }
    if(sum <= min)
    {
     min = sum;
     ind = um - count + i;
     if(um<n) ind--;
    }}
    count = 0;
    Arrays.fill(a,0);
    }
    }
    }
    for (int i = 1; i <= count-m+1 ; i++)
    {
     sum = 0;
     for (int j = i; j <= i+m-1 ; j++)
      {
        sum = sum + a[j];
       }
      if(sum <= min)
     {
       min = sum;
       ind = um - count + i ;
     }
    }
    if(ind == 0)System.out.println("0");
    else System.out.println(ind);
    }
}
My Answers:
/*
40
5
12368145698754*11111*21*111*00001000000
ans = 35

40
5
12368145698754*11111*21*111*0000100*0000
ans = 31

40
5
00001000*0000*12368145698754*11111*21*111
ans = 4
  */
Re: What is TEST#2
Posted by Muhabbat 6 Nov 2009 14:30
I give many tests to your programm, all answer is true. But I don't now why WA.
Re: What is TEST#2
Posted by Smilodon_am 8 Jan 2010 18:10
These answers are wrong.
In the first test
Ans=34
In the second test
Ans=29
In the third test
Ans=1

There is sentence in the problem statement: "If there are more than one such value for L, then write the smallest one."

And at last:
1. N and K are situated on the single (first) line
2. In some of your tests real number of symbols doesn't correspond the number N: somewhere it is less, somewhere it is more.
Re: What is TEST#2
Posted by Valentin (PSU) 4 Apr 2010 09:37
I got Crash#11
But when I wrote "if (k > n) k = n;" I got WA#7
And when "int[] a = new int[110000];" (not 100000) I got AC :)