CF1195A.Drinks Choosing

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Old timers of Summer Informatics School can remember previous camps in which each student was given a drink of his choice on the vechorka (late-evening meal). Or may be the story was more complicated?

There are nn students living in a building, and for each of them the favorite drink aia_i is known. So you know nn integers a1,a2,,ana_1, a_2, \dots, a_n , where aia_i ( 1aik1 \le a_i \le k ) is the type of the favorite drink of the ii -th student. The drink types are numbered from 11 to kk .

There are infinite number of drink sets. Each set consists of exactly two portions of the same drink. In other words, there are kk types of drink sets, the jj -th type contains two portions of the drink jj . The available number of sets of each of the kk types is infinite.

You know that students will receive the minimum possible number of sets to give all students exactly one drink. Obviously, the number of sets will be exactly n2\lceil \frac{n}{2} \rceil , where x\lceil x \rceil is xx rounded up.

After students receive the sets, they will distribute their portions by their choice: each student will get exactly one portion. Note, that if nn is odd then one portion will remain unused and the students' teacher will drink it.

What is the maximum number of students that can get their favorite drink if n2\lceil \frac{n}{2} \rceil sets will be chosen optimally and students will distribute portions between themselves optimally?

输入格式

The first line of the input contains two integers nn and kk ( 1n,k10001 \le n, k \le 1\,000 ) — the number of students in the building and the number of different drinks.

The next nn lines contain student's favorite drinks. The ii -th line contains a single integer from 11 to kk — the type of the favorite drink of the ii -th student.

输出格式

Print exactly one integer — the maximum number of students that can get a favorite drink.

输入输出样例

  • 输入#1

    5 3
    1
    3
    1
    1
    2
    

    输出#1

    4
    
  • 输入#2

    10 3
    2
    1
    3
    2
    3
    3
    1
    3
    1
    2
    

    输出#2

    9
    

说明/提示

In the first example, students could choose three sets with drinks 11 , 11 and 22 (so they will have two sets with two drinks of the type 11 each and one set with two drinks of the type 22 , so portions will be 1,1,1,1,2,21, 1, 1, 1, 2, 2 ). This way all students except the second one will get their favorite drinks.

Another possible answer is sets with drinks 11 , 22 and 33 . In this case the portions will be 1,1,2,2,3,31, 1, 2, 2, 3, 3 . Then all the students except one will gain their favorite drinks. The only student that will not gain the favorite drink will be a student with ai=1a_i = 1 (i.e. the first, the third or the fourth).

首页