题库练习 New Year Parties
← 上一题 下一题 →

A13076 | New Year Parties

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

Oh, New Year. The time to gather all your friends and reflect on the heartwarming events of the past year...

$n$ friends live in a city which can be represented as a number line. The $i$ -th friend lives in a house with an integer coordinate $x_i$ . The $i$ -th friend can come celebrate the New Year to the house with coordinate $x_i-1$ , $x_i+1$ or stay at $x_i$ . Each friend is allowed to move no more than once.

For all friends $1 \le x_i \le n$ holds, however, they can come to houses with coordinates $0$ and $n+1$ (if their houses are at $1$ or $n$ , respectively).

For example, let the initial positions be $x = [1, 2, 4, 4]$ . The final ones then can be $[1, 3, 3, 4]$ , $[0, 2, 3, 3]$ , $[2, 2, 5, 5]$ , $[2, 1, 3, 5]$ and so on. The number of occupied houses is the number of distinct positions among the final ones.

So all friends choose the moves they want to perform. After that the number of occupied houses is calculated. What is the minimum and the maximum number of occupied houses can there be?

输入格式

The first line contains a single integer $n$ ( $1 \le n \le 2 \cdot 10^5$ ) — the number of friends.

The second line contains $n$ integers $x_1, x_2, \dots, x_n$ ( $1 \le x_i \le n$ ) — the coordinates of the houses of the friends.

输出格式

Print two integers — the minimum and the maximum possible number of occupied houses after all moves are performed.

输入输出样例

输入 #1
4
1 2 4 4
输出 #1
2 4
输入 #2
9
1 1 8 8 8 4 4 4 4
输出 #2
3 8
输入 #3
7
4 3 7 1 4 3 3
输出 #3
3 6
C++ 编辑器
输入
输出