PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000282. Làm bánh trong thời gian ngắn nhất (Roti Prata)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Làm bánh trong thời gian ngắn nhất (Roti Prata)
Roti Prata
Source: SPOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Prepare at least pratas using cooks working concurrently. Cook i has rank and needs minutes for their j-th prata, with no overlap between their own tasks. Find the minimum integer completion time.
Input
First line: . Next line: followed by ranks .
Output
Print the minimum time in minutes.
Subtasks
- Subtask 1 (20 points): ; ; ().
- Subtask 2 (30 points): ; ; ; .
- Subtask 3 (50 points): ; ; ().
Examples
Input 1
10
4 1 2 3 4
Output 1
12
Explanation
At time 12, capacities are 4,3,2,2; at time 11 they are 4,2,2,1.