PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000133. Điều chỉnh hệ thống tưới nước (Watering System)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Điều chỉnh hệ thống tưới nước (Watering System)
Watering System
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
A pipe has holes with sizes . Only water from hole is useful. You pour liters and may block any holes except the first. If open hole sizes sum to , hole gets liters. Block as few holes as possible to give hole at least liters.
Input
The first line contains . The next line contains values .
Output
Print the minimum number of holes to block.
Subtasks
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input
4 10 3
2 2 2 2
Output
1
Explanation
Initially hole receives liters. Blocking one other hole reduces the open-size sum to , yielding liters. Thus one blocked hole suffices.