#BS0000161. Đom đóm vượt hang (Firefly)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Đom đóm vượt hang (Firefly)
Firefly
Source: Kattis
Version: Phuoc Hung OJ Extended
Problem Statement
A firefly flies horizontally through a cave of length and integer height . The obstacles alternate: the first is a stalagmite rising from the floor, the second a stalactite descending from the ceiling, and so on. An obstacle of length from the floor blocks levels through ; one hanging from the ceiling blocks levels through . The firefly chooses one integer level and breaks every obstacle intersecting that level. Find the minimum number it must break and the number of levels attaining that minimum.
Input
- The first line contains an even integer and an integer .
- Each of the following lines contains the length of obstacle ; odd-indexed obstacles rise from the floor and even-indexed obstacles hang from the ceiling.
Output
Print two integers: the smallest number of obstacles hit and the number of integer levels attaining it.
Subtasks
- Subtask 1 (20 points): and is even; ; for all .
- Subtask 2 (30 points): and is even; ; for all .
- Subtask 3 (50 points): and is even; ; for all .
Examples
Input
6 5
1
3
4
2
2
4
Output
3 4
Explanation
For , the floor obstacles have lengths and the ceiling obstacles . The numbers hit at levels are respectively . Thus the minimum is and four different levels attain it, so print 3 4.