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:||ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, COB, CPP 4.3.2, CPP 6.3, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, kotlin, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYPY, PYTH, PYTH 3.5, RUBY, rust, SCALA, SCM chicken, SCM guile, SCM qobi, ST, swift, TEXT, WSPC|
Fetching successful submissions
If you are still having problems, see a sample solution here.