#BS0000077. Kế hoạch dừng thang máy (Elevator Stopping Plan)
Kế hoạch dừng thang máy (Elevator Stopping Plan)
Elevator Stopping Plan
Source: LiveArchive
Version: Phuoc Hung OJ Extended
Problem Statement
A 31-floor building has requested office floors. Everyone starts at floor 1. The elevator takes 4 seconds per floor upward; each intermediate stop adds 10 seconds before it continues. After leaving at a chosen stop, a person may walk up or down at 20 seconds per floor. Choose stops to minimize the arrival time of the last person. The PHOJ version asks only for the optimal time.
Input
The first line contains . The second line contains strictly increasing requested floors.
Output
Print the minimum time in seconds.
Subtasks
- Subtask 1 — 20%: .
- Subtask 2 — 30%: .
- Subtask 3 — 50%: , requested floors in .
Example
Input
3
4 5 10
Output
46
Explanation
Stopping at floors 4 and 10 lets everyone arrive by time 46.