report VI VI EN
Register | Login
  • HOME
  • PROBLEMSET
  • ROADMAP
  • COMPETITION
  • TOPIC
  • RANKING
  • GUIDE
  • MASHUP
  • ABOUT
  • CONTACT
  • Problem
  • Submit
  • Results
Minimum maximum - MarisaOJ: Marisa Online Judge

Minimum maximum

Time limit: 1000 ms
Memory limit: 256 MB
Given an array $A$ with $n$ elements, find the smallest integer $x$ such that the array $A$ can be divided into exactly $k$ contiguous subarrays, each with a sum not exceeding $x$. ### Input - The first line contains two integers $n, k$. - The second line contains $n$ integers $A_i$. ### Output - Print an integer $x$ as the answer. ### Constraints - $1 \le k \le n \le 10^5$. - $1 \le A_i \le 10^9$. ### Sample Input: ``` 5 2 5 4 3 2 1 ``` Output: ``` 9 ``` **Note: A possible division `[5 4] [3 2 1]`. There is no way to divide $A$ if $x$ is smaller than $9$**
Binary search on answer
Reading
Minimum maximum
Beautiful number
Multiplication table
k-th digit
Maximum mean
Birthday
Sorting the differences
Collecting
Topic
Binary search
Rating 800
Solution (0) Solution