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. 【小白的CFD之旅】14 实例反思

    小白将敲门实例认真做了三遍,终于可以脱离文档直接将实例从头到尾的完成了.不过在做实例的过程中,小白 还是发现了不少的问题. 这些问题包括: 实例是从导入网格文件开始的,这网格是什么鬼? 在Models ...

  2. 【2016-10-17】【坚持学习】【Day8】【抽象工厂模式】

    定义: 提供一个创建一系列相关或相互依赖对象的接口,而无须指定它们具体的类. 结构: 抽象工厂类 具体工厂类 抽象产品类 具体产品类 例子: 代码: interface SkinFactory { B ...

  3. Oracle trunc()函数的用法

    Oracle trunc()函数的用法 /**************日期********************/1.select trunc(sysdate) from dual --2013-0 ...

  4. pcl曲面重建模块-贪婪三角形投影算法实例

    贪婪三角形投影算法 在pcl-1.8测试 #include <pcl/point_types.h> #include <pcl/io/pcd_io.h> #include &l ...

  5. PyCharm3.0默认快捷键(翻译的)

    PyCharm3.0默认快捷键(翻译的) PyCharm Default Keymap 1.编辑(Editing) Ctrl + Space    基本的代码完成(类.方法.属性)Ctrl + Alt ...

  6. 自己动手写插件底层篇—基于jquery移动插件实现

    序言 本章作为自己动手写插件的第一篇文章,会尽可能的详细描述一些实现的方式和预备知识的讲解,随着知识点积累的一点点深入,可能到了后期讲解也会有所跳跃.所以,希望知识点不是很扎实的读者或者是初学者,不要 ...

  7. 让C#可以像Javascript一样操作Json

    Json的简介 JSON(JavaScript Object Notation) 是一种轻量级的数据交换格式.它基于ECMAScript的一个子集. JSON采用完全独立于语言的文本格式,但是也使用了 ...

  8. Android开发自学笔记(Android Studio)—4.3ImageView及其子类

    一.引言 ImageView继承自View组件,主要功能用来显示图片,实际上他能显示的不仅是图片,Drawable对象都可以用ImageView来显示. ImageView派生了ImageButton ...

  9. jquery submit() 提交失败

    今天写一个表单提交 居然走到$('#wechat_form').submit() 这,但怎么都没有提交这个表单 google 了一下 Additional Notes:Forms and their ...

  10. Redis 学习(二)

    Redis可以存储以下5种数据类型 1. String 字符串 整数 浮点 2. List   一个链表 3. Set  无序收集器 4. Hash  无序散列表 5. Zset   有序集合