#P90. [CSP-S 2024] Card duels

[CSP-S 2024] Card duels

Person in Charge

Problem Description

Today is Little Q's birthday, and he received nn cards as gifts. These cards belong to the popular "Duel Monsters," where the ii-th card represents a monster with an attack power of rir_i and a defense power of rir_i.

A game consists of several rounds. In each round, Little Q will choose a monster ii and another monster j(ij)j (i \neq j), then have monster ii attack monster jj. If the attack power of monster ii is less than or equal to the defense power of monster jj, nothing happens. Otherwise, monster jj's defense is broken, and monster jj exits the game and no longer participates in the remaining rounds. Each monster can at most initiate one attack during the entire game. The game ends when all remaining monsters have initiated their attacks.

Little Q wants to determine an attack sequence such that the number of remaining monsters at the end of the game is minimized.

Input Format

The first line of input contains a positive integer nn, representing the number of cards.

The second line of input contains nn positive integers, where the ii-th integer represents the attack and defense power rir_i of the ii-th monster.

Output Format

Output a single integer representing the minimum number of remaining monsters at the end of the game.

Samples

5
1 2 3 1 2
2
10
136 136 136 2417 136 136 2417 136 136 136
8

Sample 1 Explanation

One optimal strategy is: In the first round, have monster 2 attack monster 1. In the second round, have monster 5 attack monster 4. In the third round, have monster 3 attack monster 5. At this point, all remaining monsters have initiated their attacks, and the game ends. It can be proven that no better attack sequence exists.

Sample 3

See the files duel/duel3.in and duel/duel3.ans in the contestant directory.

This sample satisfies 1in,ri2\forall 1 \le i \le n, r_i \le 2.

Sample 4

See the files duel/duel4.in and duel/duel4.ans in the contestant directory.

Data Range

For all test data, it is guaranteed that: 1n1051 \le n \le 10^5, 1ri1051 \le r_i \le 10^5.

Test Case nn rir_i Special Property
141\sim 4 10\le 10 105\le 10^5 No special properties
5105\sim 10 105\le 10^5 2\le 2
111511\sim 15 30\le 30 105\le 10^5 Special Property A
162016\sim 20 105\le 10^5 No special properties

Special Property A: Each rir_i is independently and uniformly randomly generated within the possible value range.