## Valentine's Day '19 S3 - Mathematical English

View as PDF

Points: 12 (partial)
Time limit: 0.6s
Java 1.0s
Memory limit: 64M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

You are reading a novel in English class! The novel has a total of chapters, with each chapter consisting of pages. Your teacher has broken up your class into groups, each with students, for presentations.

He wants to assign a potentially empty subarray of the chapters to each group for them to present, such that each chapter is assigned to exactly one group. Note that chapters can not be split.

Your teacher defines for all . That is, is the number of pages each student in group receives, given that group is assigned the subarray of chapters , rounded up. If group is assigned an empty subarray of chapters, then .

Since students these days care all about fairness, they will protest if their group receives more pages per student than some other group. As such, your teacher wants to assign the chapters in such a way as to minimize for all . That is, he wants to minimize the maximum number of pages per student out of all the groups.

However, your teacher is not that good at math, so he wants you to tell him, if he assigns the chapters optimally, what is the minimum of for all he can achieve?

#### Input Specification

The first line will contain two integers, .

The second line will contain integers, .

The third line will contain integers, .

#### Output Specification

Print the minimum of for all if the chapters were assigned optimally, such that every group is assigned a potentially empty subarray of chapters, and every chapter is assigned to exactly one group.

No further constraints.

#### Sample Input 1

5 3
1 3 2 4 3
2 3 2

#### Sample Output 1

2

#### Explanation For Sample 1

Group can be assigned the subarray .

Group can be assigned the subarray .

Group can be assigned the subarray .

#### Sample Input 2

5 4
1 2 5 7 10
3 2 2 1

#### Sample Output 2

4