Page 1 of 1

11237 - Halloween treats

Posted: Sat Jul 07, 2007 9:02 pm
by eonx
Could somebody post any hint how to solve this problem without exceeding time limit ?

Posted: Sat Jul 07, 2007 9:06 pm
by mf
Hint: n >= c.

Bigger hint: the solution is always possible. Think about partial sums of a's and the pigeonhole principle.

Posted: Mon Jul 09, 2007 8:50 pm
by shakil
I also get TLE. How i can improve....

Code: Select all

Cut after AC . I did not read the problem clearly.

Posted: Mon Jul 09, 2007 9:06 pm
by mf
Well you might start by learning some good indentation style and posting comments about what your code is doing.

Edit: your algorithm is clearly inefficient. Try any big input.

Posted: Thu Jul 26, 2007 8:34 pm
by hamedv
I got TLE

can any one explain his algorithm :cry:

Posted: Fri Jul 27, 2007 8:29 am
by rio
mf had gived us good hint.

Heres a little io test. You may notice something (Think why my code outputs different from sample io ... and try to make a supposition..
Input

Code: Select all

6 7
1 3 2 8 11 3 9
4 5
1 2 3 7 5
3 6
7 11 2 5 13 17
0 0
Output

Code: Select all

1 2 3
2 3 4
1 2
----
Rio

Posted: Wed Aug 01, 2007 1:55 am
by yiuyuho
mf wrote:Hint: n >= c.

Bigger hint: the solution is always possible. Think about partial sums of a's and the pigeonhole principle.


Wow, I wouldn't have come up with that in a million years. Thanks for the hint mf!

Re: 11237 - Halloween treats

Posted: Sat Jun 07, 2008 7:45 pm
by abmargb
Is the most efficient solution O(c) ?

Re: 11237 - Halloween treats

Posted: Tue Dec 30, 2008 6:23 pm
by masteringminds
Hello,

Sorry I m really a novice here, but i m asking about: what do u mean by partial sums of a's???

Thanks

Re: 11237 - Halloween treats

Posted: Wed Dec 31, 2008 7:01 am
by mf
masteringminds wrote:Sorry I m really a novice here, but i m asking about: what do u mean by partial sums of a's???

The sequence 0, a[0], a[0]+a[1], a[0]+a[1]+a[2], ...

Re: 11237 - Halloween treats

Posted: Thu Jan 01, 2009 5:07 pm
by masteringminds
Thanks very much..your hints were very helpful and I got it AC from the first time which is Weird!! But it was nice at the first day of the new year!!

Thanks again,

Re: 11237 - Halloween treats

Posted: Sun Jan 01, 2012 7:52 am
by primeobject
A easy problem...
only coding style is gonna save you... same methodology can bring you TLE or top ten(10) ranking based on how you code