PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000056. Màn ra mắt của hà mã (Hippo Circus)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Màn ra mắt của hà mã (Hippo Circus)
Hippo Circus
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
There are hippos of heights entering a gate of height . A single hippo takes time; two may enter together if the sum of heights is strictly less than , taking time. At most two hippos enter per trip. Minimize total time.
Input
Line 1: . Line 2: heights .
Output
Print Case 1: M, where is the minimum total time.
Subtasks
- Subtask 1 (20 points): ; ; ; for every ; is a positive integer.
- Subtask 2 (30 points): ; ; ; for every ; is a positive integer.
- Subtask 3 (50 points): ; ; ; for every ; is a positive integer.
Examples
Input
3 6 2 3
3 4 2
Output
Case 1: 5
Explanation
The hippos of heights 3 and 2 have total height 5, strictly below 6, so they travel together in time 3; height 4 travels alone in time 2, totaling 5.