#BS0000363. Kho tập kết lúa (Rice Hub)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Kho tập kết lúa (Rice Hub)
Rice Hub
Source: IOI
Version: Phuoc Hung OJ Extended
Problem Statement
Along a straight rural road are rice fields, numbered through . Field is at integer coordinate between and . The coordinates are given in nondecreasing order; different fields may occupy the same position.
Each field supplies one truckload per harvest. A single collection hub may be placed at any integer coordinate between and , even at an occupied field location. Transporting one truckload from field costs baht.
Select any subset of fields and a hub location so that total transport expenditure is at most baht. Find the largest number of truckloads that can be collected.
Input
The first line contains three integers : the number of fields, the maximum coordinate and the budget.
The second line contains integers in nondecreasing order.
Output
Print one integer: the maximum number of truckloads that can be collected.
Subtasks
- Subtask 1 (17 points): ; ; ; . All coordinates are distinct.
- Subtask 2 (25 points): ; ; ; .
- Subtask 3 (26 points): ; ; ; .
- Subtask 4 (32 points): ; ; ; .
Examples
Input
5 20 6
1 2 10 12 14
Output
3

Explanation
A hub at 12 serves fields 10,12,14 at cost 2+0+2=4 baht. The two consecutive groups of four have minimum distance sums 19 and 14 respectively, both over six. Hence three truckloads is optimal.