#P14453. [ICPC 2025 Xi'an R] Grand Voting

[ICPC 2025 Xi'an R] Grand Voting

题目描述

Dada organized a contest, but it received heavy downvotes. He decided to start manipulating the comments.

This contest has ss votes, initially set to 00.

There are nn participants, each with a voting parameter aia_i. When it's their turn to vote:

  • If sais \geq a_i, they cast an upvote, incrementing ss by 11.
  • If s<ais < a_i, they cast a downvote, decrementing ss by 11.

Dada can control the voting order of these nn people. He wants to know the maximum and minimum possible vote count ss in this contest.

输入格式

The first line of input contains a single integer nn (1n1051 \leq n \leq 10^5), representing the number of voters.

The next line of input contains nn integers a1,a2,,ana_1, a_2, \cdots, a_n (ai105|a_i| \leq 10^5), separated by spaces.

输出格式

Output one line containing two integers separated by a space, representing the maximum and minimum vote count ss in this contest.

5
-1 0 1 2 3
5 -5

提示

For example, if you rearrange aa to [1,0,1,2,3][-1, 0, 1, 2, 3], initially s=0s = 0. Since sa1=1s \geq a_1 = -1, the first voter casts an upvote, making s=1s = 1. Similarly, the remaining four voters also satisfy sais \geq a_i, so all cast upvotes. The final value of ss is 55, which is the maximum possible.

Conversely, if you rearrange aa to [1,2,0,3,1][1, 2, 0, 3, -1], then for each voter from left to right, s<ais < a_i holds, so all cast downvotes, resulting in s=5s = -5. This is the minimum possible. Another arrangement such as [3,2,1,0,1][3, 2, 1, 0, -1] also leads to s=5s = -5.