PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000230. Cân bằng các đống đá (Balanced Stone Heaps)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Cân bằng các đống đá (Balanced Stone Heaps)
Balanced Stone Heaps
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are piles with initial sizes . Process piles in this increasing order, exactly once.
For pile , choose a nonnegative integer with not exceeding its current size. Move stones to pile and to pile , removing stones from pile . Choosing is allowed.
Maximize the size of the smallest pile after all operations.
Input
- The first line contains .
- The next line contains integers .
Output
Print the maximum achievable minimum pile size.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
4
1 2 10 100
Output
7
Explanation
Move from pile to get . Then move from pile to get , so every pile has at least stones. A minimum of is impossible under the one-pass operation order; the answer is .