11237 - Halloween treats

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

Moderator: Board moderators

Post Reply
eonx
New poster
Posts: 1
Joined: Sat Jul 07, 2007 8:58 pm

11237 - Halloween treats

Post by eonx »

Could somebody post any hint how to solve this problem without exceeding time limit ?
mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf »

Hint: n >= c.

Bigger hint: the solution is always possible. Think about partial sums of a's and the pigeonhole principle.
shakil
Learning poster
Posts: 74
Joined: Sat Jul 15, 2006 6:28 am
Location: CUET , bangladesh
Contact:

Post by shakil »

I also get TLE. How i can improve....

Code: Select all

Cut after AC . I did not read the problem clearly.
Last edited by shakil on Mon Jul 30, 2007 12:07 pm, edited 2 times in total.
SHAKIL
mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post 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.
hamedv
Learning poster
Posts: 98
Joined: Mon May 07, 2007 8:30 am

Post by hamedv »

I got TLE

can any one explain his algorithm :cry:
rio
A great helper
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan

Post 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
yiuyuho
A great helper
Posts: 325
Joined: Thu Feb 21, 2002 2:00 am
Location: United States
Contact:

Post 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!
abmargb
New poster
Posts: 1
Joined: Sat Jun 07, 2008 7:43 pm

Re: 11237 - Halloween treats

Post by abmargb »

Is the most efficient solution O(c) ?
masteringminds
New poster
Posts: 4
Joined: Wed Jun 18, 2008 1:40 am

Re: 11237 - Halloween treats

Post 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
mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Re: 11237 - Halloween treats

Post 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], ...
masteringminds
New poster
Posts: 4
Joined: Wed Jun 18, 2008 1:40 am

Re: 11237 - Halloween treats

Post 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,
primeobject
New poster
Posts: 1
Joined: Sun Jan 01, 2012 7:47 am

Re: 11237 - Halloween treats

Post 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
Post Reply

Return to “Volume 112 (11200-11299)”