Duel of Cards

시간 제한1초메모리 제한2048 MB

요약
앨리스의 카드 n장이 주어질 때, 두 사람이 각자 덱 순서를 정하고 겨룰 때 앨리스가 얻을 수 있는 최소 및 최대 점수를 구한다.
난이도

보통10점 중 4점

유형
그리디, 정렬
정답자
아직 제출이 없습니다

문제

Alice and Bob are playing a card game. There are 2n2n cards uniquely numbered from 11 to 2n2n. The cards are shuffled and dealt to the two players so that each player gets nn cards. Each player then arranges the cards they get into a deck in any order that they choose, facing down.

The game has nn turns. In each turn, both players reveal the card that is on the top of their deck and compare the numbers on the two cards. The player with the larger card wins and scores one point. This is repeated until all cards in the decks are compared.

After getting her nn cards, Alice wonders what is the minimum and maximum number of points she may possibly score in the game.

입력

The first line of input contains a single integer nn (1≤n≤1,0001 ≤ n ≤ 1\\, 000), the number of cards that Alice gets.

The next nn lines each have a single integer between 11 and 2n2n (both inclusive) giving a card that is dealt to Alice. It is guaranteed that all those cards are unique.

출력

Output two integers, the minimum and maximum number of points Alice may score.

예제1

  1. 예제 1

    입력
    3
    2
    5
    4
    
    예상 출력
    1 2