#GD0000186. Trà và vỏ quýt (Tea with Tangerines)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Trà và vỏ quýt (Tea with Tangerines)
Tea with Tangerines
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are pieces of tangerine peel with positive integer sizes . In one operation, you may split a piece of size into exactly two positive integer pieces satisfying . Your goal is that every pair of final pieces of sizes satisfies . Find the minimum number of splitting operations.
Input
Line 1 contains the integer , the initial number of peel pieces.
Line 2 contains exactly positive integers in nondecreasing order.
Output
Print one integer: the minimum number of splits needed so that the largest final piece is strictly smaller than twice the smallest.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Example 1
Input
5
1 2 3 4 5
Output
10
Explanation
The smallest piece has size and cannot be split into smaller positive integers. To satisfy , every final piece must have size . The original sizes require respectively splits, totaling .
Example 2
Input
5
600 900 1300 2000 2550
Output
4
Explanation
Keep the pieces and . Split into (one operation), into (one), and into (two). The smallest final piece is , the largest is , and . This takes four splits, matching the minimum required number of pieces for the larger originals.