Sanghyeon's Math Study Plan
InterviewTime limit1sMemory limit1024 MB
Find the smallest constant daily problem count x so that the total favorability over N days, where each day's value is piecewise linear in x, is at least L.
- Level
Medium4 of 10
- Topics
- Binary search, Array
- Solved
- No attempts yet
Problem
A teacher at KSA likes students who study math hard, so the teacher has decided to make students study a lot of math over the next days. The teacher wants a student to solve math problems on day . The teacher's favorability toward a student depends on how many problems the student solved that day. If a student solved problems on day , the favorability increases by the following amount.
Sanghyeon wants a regular routine, so he decides to solve the same number of math problems every day for days. At first, the teacher's favorability toward Sanghyeon is . Sanghyeon wants a favorability of at least after days. Find the minimum number of problems he must solve per day.
Input
The first line contains an integer (). The second line contains integers separated by spaces (). The third line contains an integer ().
Output
Print the minimum number of math problems Sanghyeon must solve per day.