//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. laravel 路由缓存

    使用路由缓存之前,需要知晓路由缓存只能用于控制器路由,不能用于闭包路由,如果路由定义中包含闭包路由将无法进行路由缓存,只有将所有路由定义转化为控制器路由或资源路由后才能执行路由缓存命令: php ar ...

  2. MongoDB----提升

    文档之间的联系 一对一:通过文档内嵌的形式体现一对一的关系 db.user.insert({name:"xiaoming",frind:{name:"xiahua&quo ...

  3. bitset用法详解

    参见此博客: https://www.cnblogs.com/magisk/p/8809922.html

  4. centos6 防火墙iptables操作整理

    使用语句 前言:  iptables的启动文件位置再:  /etc/init.d/iptables , srevice iptables调用的就是这里的执行文件 查看防火墙状态   service i ...

  5. idea 设置选中代码得背景颜色

  6. python 图片相似度

    def pil_image_similarity(filepath1, filepath2): from PIL import Image from functools import reduce i ...

  7. 来一个使用sysbench测试cpu性能的简单脚本

    #!/bin/bash for ((i=1; i<16; i++)); do sysbench cpu run --cpu-max-prime=10000 --threads=4 --time= ...

  8. [转] Mongoose简要API

    Mongoose是在node.js环境下对mongodb进行便捷操作的对象模型工具 因此,要使用mongoose,则必须安装node.js环境以及mongodb数据库.mongoose使mongodb ...

  9. thinkphp5验证码使用

    simple 控制器中 /** * 生成验证码 * @param viod */ public function verify() { $captcha = new \think\captcha\Ca ...

  10. CentOS7中Docker-ce的卸载和安装

    一.查看是否已安装了Docker软件包: #查看是否已经安装的Docker软件包sudo yum list installed | grep docker 二.如果已安装不想要的docker/dock ...