LotteryCrawling in process... Crawling failed Time Limit:2000MS     Memory Limit:524288KB     64bit IO Format:%I64d & %I64u

Submit Status

Description

 

Input

 

Output

 

Sample Input

 

Sample Output

 

Hint

 

Description

Today Berland holds a lottery with a prize — a huge sum of money! There are k persons, who attend the lottery. Each of them will receive a unique integer from 1 to k.

The organizers bought n balls to organize the lottery, each of them is painted some color, the colors are numbered from 1 to k. A ball of color c corresponds to the participant with the same number. The organizers will randomly choose one ball — and the winner will be the person whose color will be chosen!

Five hours before the start of the lottery the organizers realized that for the lottery to be fair there must be an equal number of balls of each of k colors. This will ensure that the chances of winning are equal for all the participants.

You have to find the minimum number of balls that you need to repaint to make the lottery fair. A ball can be repainted to any of the k colors.

Input

The first line of the input contains two integers n and k (1 ≤ k ≤ n ≤ 100) — the number of balls and the number of participants. It is guaranteed that n is evenly divisible by k.

The second line of the input contains space-separated sequence of n positive integers ci (1 ≤ ci ≤ k), where ci means the original color of the i-th ball.

Output

In the single line of the output print a single integer — the minimum number of balls to repaint to make number of balls of each color equal.

Sample Input

 

Input
4 2
2 1 2 2
Output
1
Input
8 4
1 2 1 1 1 4 1 4
Output
3

Sample Output

 

Hint

In the first example the organizers need to repaint any ball of color 2 to the color 1.

In the second example the organizers need to repaint one ball of color 1 to the color 2 and two balls of the color 1 to the color 3.

/*
大水题,最后才看到真是可惜啊
k个人n个球,n是k的倍数
每个人都有初始的球数,让你球使每个人的球数都相等的,最少要改变多少球数
*/
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#define N 105
using namespace std;
int n,k,x;
int a[N];
int main()
{
while(~scanf("%d%d",&n,&k))
{
memset(a,,sizeof a);
int ave=n/k;
for(int i=;i<=n;i++)
{
scanf("%d",&x);
++a[x];
}
int ans=;
for(int i=;i<=k;i++)ans+=abs(a[i]-ave);
printf("%d\n",ans>>);
}
return ;
}

2015-2016 ACM-ICPC, NEERC, Southern Subregional Contest I Lottery的更多相关文章

  1. 2018-2019 ICPC, NEERC, Southern Subregional Contest

    目录 2018-2019 ICPC, NEERC, Southern Subregional Contest (Codeforces 1070) A.Find a Number(BFS) C.Clou ...

  2. Codeforces 2018-2019 ICPC, NEERC, Southern Subregional Contest

    2018-2019 ICPC, NEERC, Southern Subregional Contest 闲谈: 被操哥和男神带飞的一场ACM,第一把做了这么多题,荣幸成为7题队,虽然比赛的时候频频出锅 ...

  3. 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror) Solution

    从这里开始 题目列表 瞎扯 Problem A Find a Number Problem B Berkomnadzor Problem C Cloud Computing Problem D Gar ...

  4. Codeforces1070 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)总结

    第一次打ACM比赛,和yyf两个人一起搞事情 感觉被两个学长队暴打的好惨啊 然后我一直做傻子题,yyf一直在切神仙题 然后放一波题解(部分) A. Find a Number LINK 题目大意 给你 ...

  5. codeforce1070 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred) 题解

    秉承ACM团队合作的思想懒,这篇blog只有部分题解,剩余的请前往星感大神Star_Feel的blog食用(表示男神汉克斯更懒不屑于写我们分别代写了下...) C. Cloud Computing 扫 ...

  6. 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)

    A. Find a Number 找到一个树,可以被d整除,且数字和为s 记忆化搜索 static class S{ int mod,s; String str; public S(int mod, ...

  7. 2018.10.20 2018-2019 ICPC,NEERC,Southern Subregional Contest(Online Mirror, ACM-ICPC Rules)

    i207M的“怕不是一个小时就要弃疗的flag”并没有生效,这次居然写到了最后,好评=.= 然而可能是退役前和i207M的最后一场比赛了TAT 不过打得真的好爽啊QAQ 最终结果: 看见那几个罚时没, ...

  8. 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred) Solution

    A. Find a Number Solved By 2017212212083 题意:$找一个最小的n使得n % d == 0 并且 n 的每一位数字加起来之和为s$ 思路: 定义一个二元组$< ...

  9. 【*2000】【2018-2019 ICPC, NEERC, Southern Subregional Contest C 】Cloud Computing

    [链接] 我是链接,点我呀:) [题意] [题解] 我们可以很容易知道区间的每个位置有哪些安排可以用. 显然 我们优先用那些花费的钱比较少的租用cpu方案. 但一个方案可供租用的cpu有限. 我们可以 ...

  10. 2018-2019 ICPC, NEERC, Southern Subregional Contest (codeforces 1070)

    A. 直接从状态(0,0)bfs, 这样一定是最小的 #include <iostream> #include <sstream> #include <algorithm ...

随机推荐

  1. XML(二)之DTD——XML文件约束

    前面介绍了XML的作用和基本的格式,今天我给大家分享的是关于XML的约束.废话不多说,我们直接来正题! 一.DTD简介 1.1.DTD概述 DTD(Document Type Definition,文 ...

  2. webpack2系列step1

    第一篇:HTML 本文将一步一步的介绍webpack2的配置,从最基础的一直到与node结合. 操作都一样: midir step1 && cd step1 npm init -y n ...

  3. Linux学习——yum学习和光盘yum源搭建

    在rmp安装的时代,rpm包依赖让安装人员头大,而且头疼,有了yum后整个的安装更加简单和方便. yum源文件 1.yum源的介绍: 将所有的软件包放到官方服务器上,当进行yum在线安装时,可以自动解 ...

  4. mybatis错误——java.io.IOException: Could not find resource com/xxx/xxxMapper.xml

    在学习Mybatis的时候,参考网上的教程进行简单demo的搭建,配置的没有问题,然后出现了下面的错误! Exception in thread "main" java.lang. ...

  5. 微信支付之h5方式(非微信内置浏览器中支付)

    这两天完成了公司网站手机和PC端的支付对接,就是支付宝和微信. 对接完后有所感触,我们来聊一聊,微信支付的坑,为什么这么说呢,因为我在对接完支付宝后是很愉快的,基本上在demo上稍加修改就ok了, 对 ...

  6. 记一次Java的内存泄露分析

    当前环境 jdk == 1.8 httpasyncclient == 4.1.3 代码地址 git 地址:https://github.com/jasonGeng88/java-network-pro ...

  7. ASP.NET没有魔法——ASP.NET MVC & 分层

    上一篇文章简要说明了MVC所代表的含义并提供了详细的项目及其控制器.视图等内容的创建步骤,最终完成了一个简单ASP.NET MVC程序. 注:MVC与ASP.NET MVC不相等,MVC是一种开发模式 ...

  8. springboot与thrift集成实现服务端和客户端

    我们这里用一个简单的小功能来演示一下如何使用springboot集成thrift 这个功能是,判断hdfs路径存在. 1.先解决依赖 <dependencies> <dependen ...

  9. JavaScript实现模糊推荐的input框(类似百度搜索框)

    如何用JS实现一个类似百度搜索框的输入框呢,再填充完失去焦点时,自动填充配置项,最终效果如下图: 实现很简单,但是易用性会上升一大截,需要用到的有jquery-ui的autocomplete,jque ...

  10. 基于Redis位图实现系统用户登录统计

    项目需求,试着写了一个简单登录统计,基本功能都实现了,日志数据量小.具体性能没有进行测试~ 记录下开发过程与代码,留着以后改进! 1. 需求 1. 实现记录用户哪天进行了登录,每天只记录是否登录过,重 ...