Squirrel and chestnutProblem code: SQUIRREL |
All submissions for this problem are available.
There are n squirrel(s) waiting below the feet of m chestnut tree(s). The first chestnut of the i-th tree will fall right after Ti second(s), and one more every Pi second(s) after that. The “big mama” of squirrels wants them to bring their nest no less than k chestnuts to avoid the big storm coming, as fast as possible! So they are discussing to wait below which trees to take enough chestnuts in the shortest time. Time to move to the positions is zero, and the squirrels move nowhere after that.
Request
Calculate the shortest time (how many seconds more) the squirrels can take enough chestnuts.
Input
- The first line contains an integer t, the number of test cases, for each:
- The first line contains the integers m,n,k, respectively.
- The second line contains the integers Ti (i=1..m), respectively.
- The third line contains the integers Pi (i=1..m), respectively.
(Each integer on a same line is separated by at least one space character, there is no added line between test cases)
Output
For each test cases, output in a single line an integer which is the shortest time calculated.
Example
Input:
2 3 2 5 5 1 2 1 2 1 3 2 5 5 1 2 1 1 1
Output:
4 3
* Explain (case #1): 2 squirrels waiting below the trees 2 and 3.
Limitations
- 0<t?20
- 0<m,n?10,000
- 0<k?107
- 0<Ti,Pi?100
| Author: | anhdq |
| Date Added: | 5-05-2010 |
| Time Limit: | 1 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TEXT, WSPC |
Comments

Fetching successful submissions

The input does not satisfy
The input does not satisfy the constraints provided. Which have missing symbols again, as well.
There are issues with several
There are issues with several of the problem statements. For this problem, the input begins with an integer giving number of cases, then each case is as described, but m and n can be up to 10000
and time limit seems to not
and time limit seems to not be 2s ?
looks like time limit is not
The time limit is two
The time limit is two seconds.
if time limit is 2s then how
if time limit is 2s then how solutions are accepted ,those took more than 2s(2.03-3.61)??
@ shishir there can be
@ shishir there can be multiple files
does the value of time is
does the value of time is limited by something( ie does it fit into a long?)
here num of squirrels <= num
here num of squirrels <= num of tress right ?? if not what happens when many squirrels are under same tree
Time limit for each case is
Time limit for each case is 2s. The displayed time is total time for all the testcases.
@Ankit Think what will happen
@Ankit
Think what will happen and you will arrive at the answer
One squirrel can carry any
One squirrel can carry any number of chestnuts, right?
will many squirrels under the
will many squirrels under the same tree make any difference??...there is no maximum capacity for squirrel so i think 1 squirrel per tree is same is many under the same...
@vishal question is
@vishal question is sufficient to answer your query.
i am again and again gettin
i am again and again gettin runtime error- segmentation faults.. i have used arrarys of sizes 777 (3 arrays) and m takin input using the getchar function... (as is necessary acc to the problems) should i initialize them to zero in order to prevent this error from arising?? although they work absolutely fine at my pc
please help me out people, i am a newbee.
@Raman: The problem statement
@Raman: The problem statement was changed. 777 is not the upper limit, 10000 is.
@David.. thanks , i changed
@David.. thanks , i changed it, but it is still showing a run time error
@Raman: I responded your
@Raman: I responded your first question because it was directly related to a mistake in the problem statement, however you really shouldn't have asked the question in the first place because it is a violation of the contest rules to help or be helped by others, or discuss solving strategies of any kind.
@David.. oh m sry man.. i
@David.. oh m sry man.. i became a member yesterday.. not aware d d rules :)
I am unable to submit
I am unable to submit solution, anyone facing the same issue? when the submit request takes a long time to respond and returns back to same page with no sumbissions made.
i am using firefox, is it
i am using firefox, is it supported?
squirrels are standing under
squirrels are standing under trees. Can they move from one tre to another.
once a squirrel stand below one tree, does it hve to stand below same till last?
sorry i got the ans. i didnt
sorry i got the ans. i didnt read nealy first. :)
I am still unable to submit
I am still unable to submit any solution. HELP!!!!! PLEASE!!!!!!!!!!!!!!!!!
@Dinesh Salve: "and the
@Dinesh Salve: "and the squirrels move nowhere after that"
the time limit is 1 sec..
the time limit is 1 sec.. come on!!
when does it give runtime
when does it give runtime error(other)?
I am using only 2.46M but still its giving the same error.
admin help i have done the
admin help
i have done the code and it makes the output in a correct way but it tells me wrong answer
hey earlier time limit was 2
hey earlier time limit was 2 sec..come on..time limit only 1 sec?
The time limit was actually 1
The time limit was actually 1 second the entire time, but incorrectly being displayed as 2 seconds.
If my code was accepted, can
If my code was accepted, can i resubmit? I want to improve my rank
i dont know whats the
i dont know whats the problem
the values for which i m testing my code to its giving right o/p
but in the result its showing wrong ans
plz sm1 help
thank you
The time limit is for all the
The time limit is for all the test cases or is it for only one????
@Durvasula Rohit: 1s for a
@Durvasula Rohit: 1s for a set of all T test cases ;-)
my ans for above test case
my ans for above test case are coorect but it stilll give me run time error .
what about if no of squirrel >no of nut tree
how come people are
how come people are getting 3-4 sec when the time limit is only 1 sec!!!!!
Because they read
Because they read instructions like 'Have you browsed through the FAQ?' that appears below 'Post new comment' :P
time limit exceeding every
time limit exceeding every time..
what to do..
Comment edited by Admin.
Comment edited by Admin.
@TeamCyclone: You are not
@TeamCyclone: You are not supposed to post code. You will be banned if you further violate the rules!
Извините
what happen if n>m? getting
sorry if above is discussion
sorry if above is discussion of any statagy to approach to problem. Anyway this will surly give TLE if it gives corrcet answer. But i just want to know for n>m.
The problem statement isn't
The problem statement isn't really specific enough so I think it is fine to answer that. I guess squirrels can choose the same tree. But all but one of those who do would end up not doing much.
I don't understand the
I don't understand the mistake in my WA code and ACCEPTED code. I request to discuss it after end of contest.
sorry now i understood my
I am getting a runtime error,
I am getting a runtime error, Kindly help i am new.
@Stephen Merriman: they can
@Stephen Merriman: they can stay at a same tree, but the number of squirrels they will get in total stay the same too!
@Pankaj kumar: thanks for realizing your error, so it is better for everyone to check your code before asking, since in fact this problem is having the highest number of AC codes. :-)
I am a newbie to this
I am a newbie to this contest.
i am having a runtime error. May I know what's the memory limitation ? and any tips to minimise the memory usage.
I'm afraid there's not much
I'm afraid there's not much more anyone can do while the contest is on but suggest you read the FAQ.
I submitted my solution 2nd
I submitted my solution 2nd time and got better time....but there is no update in the rank list...why so?
now that the challenge has
now that the challenge has ended. could someone give me a hint on the p'ble soln. I tried creating a sequence on on first n series ( with least Pi + Ti) , but, my soln gives TLE. Would appreciate any hint
I used binary search. Given a
I used binary search. Given a particular moment in time, calculate how many chestnuts each tree has dropped, sort, and add up the N biggest values. If that is at least k, that time is an upper limit, else it is a lower limit.
do you think using a scanf
do you think using a scanf for each Pi and Ti would make my soln slower?
@sanjay: no, not that. you
@sanjay: no, not that. you have to read in all the input anyway. After T seconds, there would be Ni = max(0, 1+(T-Ti)/Pi) nuts. And you need to find the smallest T for which the top N trees (or M trees, if M < N) sum to at least k nuts.
Straight forward way is to check for T=0, 1, ...; but that will take a lot of time. You use binary search to find that minimum T because the sum of nuts under the top min(N,M) trees will be always increasing. (monotone property.)
check top 7 accepted
check top 7 accepted solutions for this case:
1
3 2 4
1 2 23
20 20 2
answer shold be 22 but u'll get surprise to see ;AC solutions will give different answers(but not 22 :p).
codechef needs to improve their test cases quality.
^ if you're including my
^ if you're including my solution in the list ... i hope you commented the line 26 (freopen). :)
Plus , others could be using some sort of buffering technique ... which can give unexpected results when the input isn't fed from a file.