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 21 2 3 2

output
2 11 2 1 2 

input
7 31 3 2 2 2 2 1

output
2 11 3 3 2 2 2 1 

input
4 41000000000 100 7 1000000000

output
1 41 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 = 3005;
int n,m,b[maxn],a[maxn],cge[maxn][maxn],cge_a[maxn];
int ans1,ans2;
int cnt = 1,t;
int main(){cin>>n>>m;for(int i = 1;i <= n;i++){cin>>a[i];if(a[i] <= m) b[a[i]]++;}ans1 = n / m;for(int i = 1;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 = 1;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 = 1;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 0;
}

转载于:https://www.cnblogs.com/hyfer/p/5929949.html

cf723c Polycarp at the Radio相关推荐

  1. cf-723C Polycarp at the Radio

    cf-723C Polycarp at the Radio 题目点击打开链接  http://codeforces.com/contest/723/problem/C 分析:先定义每个数字在数组中出现 ...

  2. 【Codeforces】Round #375 (Div. 2)

    Position:http://codeforces.com/contest/723 我的情况 啊哈哈,这次raiting肯定要涨,接受过上次的教训,先用小号送肉,大号都是一发切,重回蓝咯 结果... ...

  3. 2016区域赛前冲刺训练

    UPD 2016.10.23 shift-and (2题) Codeforces 训练 现在已经完成了: 191 [Codeforces Round #377] (6/6) Div 2 A Buy a ...

  4. linux touch命令对于windows,Windows代替touch命令

    codeforces 723C : Polycarp at the Radio Description Polycarp is a music editor at the radio station. ...

  5. CSS3重新定义input中呆若木鸡的默认复选框CheckBox和单选框Radio样式

    <!DOCTYPE html> <html> <head><meta charset="UTF-8"><style>/* ...

  6. thymeleaf : input/select/radio回显

    thymeleaf中不用自己去写checked="checked" selected="selected"这种代码,他自己会选. input <input ...

  7. 解决:angularjs radio默认选中失效问题

    添加ng-model后checked="checked"失效,可见angularjs也不好,会失效html标准属性 解决:添加ng-checked="1" &l ...

  8. html中radio、checkbox选中状态研究(静下心来看,静下心来总结)

    html中radio.checkbox选中状态研究(静下心来看,静下心来总结) 一.总结 1.单选框的如果有多个checked 会以最后一个为准 2.js动态添加checked属性:不行:通过 $(& ...

  9. radio根据name 获取选中值及判断是否被选中

    $('input:radio[name="fjscfs"]:checked').val(); 根据id判断是否被选中 if($("#A26").is(" ...

最新文章

  1. 关于CLR、CIL、CTS、CLS、CLI、BCL和FCL
  2. .jsp与servlet之间页面跳转及参数传递实例
  3. python yolo-v2 设计批处理程序对训练生成的权重文件进行自动化批量测试,并输出结果到指定txt文件
  4. 微信二次开发SDK使用教程--手机检测到有人点赞/取消点赞通知服务端
  5. 【vue报错】——listen EADDRINUSE :::8080 解决方案
  6. React-Native-lesson
  7. C. Number of Pairs
  8. UVA - 1588 ​​​​​​​Kickdown
  9. 腾讯视频app官方下载_腾讯视频怎么快进
  10. python函数参数定义顺序_18 Python - 函数定义与参数
  11. CSS 子元素铺满整个父元素、CSS + JQuery 实现遮罩层
  12. densenet代码解读
  13. Srm32 dwm1000 tdoa定位源码
  14. c语言求最大质数,【C语言】求解素数(质数)的N种境界
  15. php 改变图片大小,如何把照片尺寸改小 电子照片尺寸怎么改
  16. 桌面计算机图标双击打不开了,双击打不开图标怎么办 双击打不开图标解决方法【详解】...
  17. golang 域名 转 ip
  18. 基于Android的共享单车系统的设计与应用
  19. 同为IM社交产品中的王者,QQ与微信到底有什么区别
  20. NMI 代码实现步骤

热门文章

  1. UE4.27 制作过场动画
  2. 手机电子邮件如何绑定公司企业邮箱
  3. Reeds-Shepp曲线和Dubins曲线相关资料汇总
  4. 数据库不同数据类型的字段插入数据能成功----将varchar类型数据插入到int中成功了。
  5. IDEA 方法设置快速注释【便捷】
  6. 什么是ChaGpt?
  7. 让小Yi摄像头启用RTSP
  8. Oracle里面constraint说明
  9. C Sharp进行全站仪的圆曲线整桩位计算
  10. JZ54---字符流中第一个不重复的字符