//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. LeetCode(112):路径总和

    Easy! 题目描述: 给定一个二叉树和一个目标和,判断该树中是否存在根节点到叶子节点的路径,这条路径上所有节点值相加等于目标和. 说明: 叶子节点是指没有子节点的节点. 示例: 给定如下二叉树,以及 ...

  2. 操作dom获取datatable中的某一行的某一列的数据

    需求描述:编辑的时候,点击的那一行,进入后台的验证方法,验证通过后,再进入编辑页面,进入的时候需要把本行<tr>数据中的某一列<td>的值传递过去 思路表述:之前我想的是,给列 ...

  3. 【python】声明编码的格式

    来自:http://www.xuebuyuan.com/975181.html 编码声明必须在第一行或者第二行,且要符合正则表达式 "coding[:=]\s*([-\w.]+)" ...

  4. PHP实现动态获取函数参数的方法

    1. func_num_args — 返回传入函数的参数总个数 int func_num_args ( void ) 示例 <?php function demo () { $numargs = ...

  5. python DLL接口测试

    #coding=utf-8 import clr import sys import threading from itertools import permutations sys.path.app ...

  6. 饮冰三年-人工智能-linux-08 软件包管理(Python的安装)

    1:软件包存放的位置 media/CentOS_6.9_Final/Packages文件夹下 2.RPM就是Red Hat Package Manger(红帽软件包管理工具)的缩写. 2.1 常用的命 ...

  7. EF Core Fluent API

    多对多配置 先安装 Install-Package MySql.Data.EntityFrameworkCore 创建3个表 创建类 public class Role { public long I ...

  8. Oracle数据重复,只取一条

    --方法一 select * from tb_supply where rowid=any(select max(rowid) from tb_supply group by phone_id) -- ...

  9. python---通过递归和动态规划策略解决找零钱问题

    也是常见套路. # coding = utf-8 def rec_mc(coin_value_list, change, know_results): min_coins = change if ch ...

  10. MySQl 查询性能优化相关

    0. 1.参考 提升网站访问速度的 SQL 查询优化技巧 缓存一切数据,读取内存而不是硬盘IO 如果你的服务器默认情况下没有使用MySQL查询缓存,那么你应该开启缓存.开启缓存意味着MySQL 会把所 ...