Squirrel and chestnut
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.
Calculate the shortest time (how many seconds more) the squirrels can take enough chestnuts.
- 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)
For each test cases, output in a single line an integer which is the shortest time calculated.
2 3 2 5 5 1 2 1 2 1 3 2 5 5 1 2 1 1 1
* Explain (case #1): 2 squirrels waiting below the trees 2 and 3.
|Tags||anhdq, june10, medium|
|Time Limit:||0.169935 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, rust, SCALA, swift, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, kotlin, PERL6, TEXT, SCM chicken, PYP3, CLOJ, COB, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.