//AC代码。。。表示很晕
#include <iostream>
using namespace std;
int a[],b[];
int main()
{
int n,m,cnt;
cin >> n >> m;
int t = n/m;
int t2 = n%m;
if(n%m == ) cnt = t;
else cnt = t+;
for(int i=; i<n; ++i)
{
cin >> a[i];
if(a[i] <= m) ++b[a[i]];
if(a[i] <= m && t2 > && b[a[i]] == cnt) --t2;
}
int f = ;
int ans = ;
if(t2 == ) cnt = t;
//cout << cnt << endl;
for(int i=; i<n; ++i)
{
if(a[i] > m ||(a[i] <=m && b[a[i]] > cnt))
{
while(f <= m)
{
//cout <<"test" << f << " " << cnt << endl;
if(b[f] < t) break;
++f;
}
if(f <= m)
{
++ans;
if(a[i] <= m)
--b[a[i]];
a[i] = f;
++b[f];
//cout <<t2 << "bf " << b[f] <<" " << cnt << endl;
if(t2 > && b[f] == cnt )
if((--t2) == ) cnt = t;
if(a[i] <= m && t2 > && b[a[i]] == cnt)
if((--t2) == ) cnt = t;
}
}
}
cout << t << " " << ans << endl;
for(int i=; i<n; ++i)
if(i == )
cout << a[i];
else
cout << " " << a[i];
cout << endl;
return ;
}

codeforces723----C. 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. cf723c Polycarp at the Radio

    Polycarp is a music editor at the radio station. He received a playlist for tomorrow, that can be re ...

  4. codeforces 723C : Polycarp at the Radio

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

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

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

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

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

  7. C. Polycarp at the Radio

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

  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. 【python】python为何多线程无法切换

    写了一个kafka传输消息,celery发布任务的脚本. 有四个线程,分别读取不同的kafka队列信息 问题是,只有第一个线程会启动,剩下的三个线程连start都运行不了. 而且这个问题不是一开始就发 ...

  2. 刷《剑指offer》笔记

    本文是刷<剑指offer>代码中的学习笔记,学习ing.. 衡量时间和空间. 递归的代码较为简洁,但性能不如基于循环的实现方法.

  3. Niagara物联网框架机制二(笔记)

    一.Niagara框架 1.一个Niagara 系统中有四种典型的Programs,这些程序间的关系及其网络通讯关系可通过下面的通讯图表解释 2. Niagara  Programs station ...

  4. Decimal integer conversion

    问题 : Decimal integer conversion 时间限制: 1 Sec  内存限制: 128 MB 题目描述 XiaoMing likes mathematics, and he is ...

  5. IDEA创建第一个项目详细过程

  6. 常见的爬虫分析库(3)-Python正则表达式与re模块

    在线正则表达式测试 http://tool.oschina.net/regex/ 常见匹配模式 模式 描述 \w 匹配字母数字及下划线 \W 匹配非字母数字下划线 \s 匹配任意空白字符,等价于 [\ ...

  7. HDU 1247 Hat’s Words(字典树活用)

    Hat's Words Time Limit : 2000 / 1000 MS(Java / Others)    Memory Limit : 65536 / 32768 K(Java / Othe ...

  8. ORA-01536: 超出表空间 'tablespace_name' 的空间限额

    表空间限额问题知识总结:    表空间的大小与用户的配额大小是两种不同的概念    表空间的大小是指实际的用户表空间的大小,而配额大小指的是用户指定使用表空间的的大小    把表空间文件增大,还是出现 ...

  9. HTML文本格式化与HTML 超链接

    文本格式化<b>加粗文本</b><i>斜体文本</i><code>电脑自动输出</code><sub> 下标< ...

  10. [Bjoi2018]二进制

    题解: 首先发现性质 只有1个1的区间 或者 奇数个1且0的个数少于2这个区间是不合法的 然后这个东西暴力是比较好处理的 刚开始写的比较傻逼,分几种情况 先把0,1缩在一起 1.k1个0+1+k2个0 ...