Polycarp is a music editor at the radio station. He received a playlist for tomorrow, that can be represented as a sequence a1, a2, ..., an, where ai is a band, which performs the i-th song. Polycarp likes bands with the numbers from 1 to m, but he doesn't really like others.

We define as bj the number of songs the group j is going to perform tomorrow. Polycarp wants to change the playlist in such a way that the minimum among the numbers b1, b2, ..., bm will be as large as possible.

Find this maximum possible value of the minimum among the bj (1 ≤ j ≤ m), and the minimum number of changes in the playlist Polycarp needs to make to achieve it. One change in the playlist is a replacement of the performer of the i-th song with any other group.

Input

The first line of the input contains two integers n and m (1 ≤ m ≤ n ≤ 2000).

The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 109), where ai is the performer of the i-th song.

Output

In the first line print two integers: the maximum possible value of the minimum among the bj (1 ≤ j ≤ m), where bj is the number of songs in the changed playlist performed by the j-th band, and the minimum number of changes in the playlist Polycarp needs to make.

In the second line print the changed playlist.

If there are multiple answers, print any of them.

Examples
input
4 2
1 2 3 2
output
2 1
1 2 1 2
input
7 3
1 3 2 2 2 2 1
output
2 1
1 3 3 2 2 2 1
input
4 4
1000000000 100 7 1000000000
output
1 4
1 2 3 4

Note

In the first sample, after Polycarp's changes the first band performs two songs (b1 = 2), and the second band also performs two songs (b2 = 2). Thus, the minimum of these values equals to 2. It is impossible to achieve a higher minimum value by any changes in the playlist.

In the second sample, after Polycarp's changes the first band performs two songs (b1 = 2), the second band performs three songs (b2 = 3), and the third band also performs two songs (b3 = 2). Thus, the best minimum value is 2.

/*
给一个数列,代表每每首歌谁负责唱,要让前m个歌手中演唱曲数最少的最多,求一个最少修改次数
贪心即可,so water
*/
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn = ;
int n,m,b[maxn],a[maxn],cge[maxn][maxn],cge_a[maxn];
int ans1,ans2;
int cnt = ,t;
int main(){
cin>>n>>m;
for(int i = ;i <= n;i++){
cin>>a[i];
if(a[i] <= m) b[a[i]]++;
}
ans1 = n / m;
for(int i = ;i <= n;i++){
while(b[cnt] >= ans1) cnt++;
if(cnt > m) break;
if(a[i] > m){
a[i] = cnt;
b[cnt]++;
ans2++;
}
}
for(int i = ;i <= m;i++){
while(b[i] > ans1){
while(b[cnt] >= ans1) cnt++;
if(cnt > m) break;
b[i]--;
cge_a[i]++;
cge[i][cge_a[i]] = cnt;
b[cnt]++;
ans2++;
}
if(cnt > m) break;
}
cout<<ans1<<" "<<ans2<<endl;
for(int i = ;i <= n;i++){
if(a[i] <= m)if(cge_a[a[i]]){
t = a[i];
a[i] = cge[t][cge_a[t]];
cge_a[t]--;
}
cout<<a[i]<<" ";
}
return ;
}

cf723c Polycarp at the Radio的更多相关文章

  1. Codeforces 723C. Polycarp at the Radio 模拟

    C. Polycarp at the Radio time limit per test: 2 seconds memory limit per test: 256 megabytes input: ...

  2. Codeforces Round #375 (Div. 2) C. Polycarp at the Radio 贪心

    C. Polycarp at the Radio time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  3. codeforces 723C : Polycarp at the Radio

    Description Polycarp is a music editor at the radio station. He received a playlist for tomorrow, th ...

  4. 【23.48%】【codeforces 723C】Polycarp at the Radio

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  5. 【Codeforces 723C】Polycarp at the Radio 贪心

    n个数,用最少的次数来改变数字,使得1到m出现的次数的最小值最大.输出最小值和改变次数以及改变后的数组. 最小值最大一定是n/m,然后把可以改变的位置上的数变为需要的数. http://codefor ...

  6. C. Polycarp at the Radio

    这题题意不太好理解,但是可以通过样例推.主要考察思维的全面性,注意把b[m]特殊处理下. AC代码: #include<cstdio> #include<cstring> co ...

  7. codeforces723----C. Polycarp at the Radio

    //AC代码...表示很晕 #include <iostream> using namespace std; ],b[]; int main() { int n,m,cnt; cin &g ...

  8. Codeforces Round #375 (Div. 2) Polycarp at the Radio 优先队列模拟题 + 贪心

    http://codeforces.com/contest/723/problem/C 题目是给出一个序列 a[i]表示第i个歌曲是第a[i]个人演唱,现在选出前m个人,记b[j]表示第j个人演唱歌曲 ...

  9. CodeForces 723C Polycarp at the Radio (题意题+暴力)

    题意:给定 n 个数,让把某一些变成 1-m之间的数,要改变最少,使得1-m中每个数中出现次数最少的尽量大. 析:这个题差不多读了一个小时吧,实在看不懂什么意思,其实并不难,直接暴力就好,n m不大. ...

随机推荐

  1. J2EE基础之JSP

    J2EE基础之JSP 1.JSP简介 JSP是JavaServer的缩写,是由Sun Microsystems公司倡导.许多公司参与一起建立的一种动态网页技术标准.在HTML文件中加入Java程序代码 ...

  2. 综合实战--文件上传系统【JDBC&IO&Socket】

    本文纯属记录第一次实战遇到的坑和知识,如果后边有时间再做整理. 1,先写了个操作数据库的工具类SqlTool,照着JDBC资料打完之后,测试的时候出错了,java.lang.ClassNotFound ...

  3. [No00006A]Js的addEventListener()及attachEvent()区别分析【js中的事件监听】

    1.添加时间监听: Chrom中: addEventListener的使用方式: target.addEventListener(type, listener, useCapture); target ...

  4. Java.utils.Collections学习

    阅读类库代码是有意义的,尤其是Java集合类框架以及算法Collections Arrays都是值得阅读的, 一来可以减少新手程序员的编码的工作量,二来,对于常见的需求,程序员应该先找下是否有现成的类 ...

  5. 数据库_MYSQL

     数据库简介 数据库分类:关系型数据库.非关系型数据库 常用的关系型数据库有:orcale .mysql .sql server等等 常用的非关系型数据库有: Memcached.redis.mong ...

  6. insert、update select from

    1.insert select from <一棵树-博客园> 收集整理,转载请注明出处! 使用SELECT INTO 和 INSERT INTO SELECT 表复制语句了. 1.INSE ...

  7. jmeter(八)断言

    jmeter中有个元件叫做断言(Assertion),它的作用和loadrunner中的检查点类似: 用于检查测试中得到的响应数据等是否符合预期,用以保证性能测试过程中的数据交互与预期一致. 使用断言 ...

  8. CentOS 6.5 PPTPD VPN服务器安装,解决807等问题。

    需要两个组件: ppp pptpd 需要配置的地方有三处: /etc/pptpd.conf /etc/ppp/options.pptpd /etc/ppp/chap-secrets 需要开启IP转发: ...

  9. manachor

    在原字符串每个字符间各插入一个未曾出现的字符,在字符串头插入另一个未出现的字符防止越界,求出的p[i]-1既为以i为中心的最长回文串的长度 void manacher(){ ,id; ;i<=n ...

  10. setTimeout,setInterval原理

    function a() { setTimeout(function(){alert(1)},0); alert(2); } a(); 和其他的编程语言一样,Javascript中的函数调用也是通过堆 ...