codeforces723----C. Polycarp at the Radio
//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的更多相关文章
- Codeforces 723C. Polycarp at the Radio 模拟
C. Polycarp at the Radio time limit per test: 2 seconds memory limit per test: 256 megabytes input: ...
- 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 ...
- cf723c Polycarp at the Radio
Polycarp is a music editor at the radio station. He received a playlist for tomorrow, that can be re ...
- codeforces 723C : Polycarp at the Radio
Description Polycarp is a music editor at the radio station. He received a playlist for tomorrow, th ...
- 【23.48%】【codeforces 723C】Polycarp at the Radio
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【Codeforces 723C】Polycarp at the Radio 贪心
n个数,用最少的次数来改变数字,使得1到m出现的次数的最小值最大.输出最小值和改变次数以及改变后的数组. 最小值最大一定是n/m,然后把可以改变的位置上的数变为需要的数. http://codefor ...
- C. Polycarp at the Radio
这题题意不太好理解,但是可以通过样例推.主要考察思维的全面性,注意把b[m]特殊处理下. AC代码: #include<cstdio> #include<cstring> co ...
- 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个人演唱歌曲 ...
- CodeForces 723C Polycarp at the Radio (题意题+暴力)
题意:给定 n 个数,让把某一些变成 1-m之间的数,要改变最少,使得1-m中每个数中出现次数最少的尽量大. 析:这个题差不多读了一个小时吧,实在看不懂什么意思,其实并不难,直接暴力就好,n m不大. ...
随机推荐
- Java面向对象(二)
一.封装 1.为什么要使用封装在类的外部直接操作类的属性是”不安全的"2.如何实现封装 1).属性私有化:设置属性的修饰符为private 2) .提供公共的set和get方法赋值 ...
- linux-umount挂载点无法卸载:device is busy(解决)
umount不了的原因一般是由于有程序有用户在占用 解决方法: 1. 首先查找谁在占用:#fuser /mnt/nfs 得到进程号. 2. 查找进程:#ps –ef|grep 进程 ...
- 微信小程序 Video默认横屏
wxml文件 <video id='myvideo' src='你的视频文件路径'> </video> js文件 onLoad: function (options) { va ...
- ffmpeg切割视频
using System.Diagnostics; public static void carveVideo() { var inputpath = @"d:\1.mp4"; v ...
- caffe入门-人脸检测1
最近刚入门caffe,跟着视频做了一个简单人脸检测.包括人脸二分类模型+方框框出人脸. 人脸二分类模型 1. 收集数据 我用的是lfw数据集,总共有13233张人脸图片.非人脸数据有两种选择.1. 用 ...
- Dom,查找标签和操作标签
Dom,查找标签和操作标签 文档对象模型(Document Object Model,DOM)是一种用于HTML和XML文档的编程接口.它给文档提供了一种结构化的表示方法,可以改变文档的内容和呈现方式 ...
- WinRAR 0day漏洞
WinRAR 0day漏洞(附利用过程) 英国安全机构Mohammad Reza Espargham的漏洞实验室发现,流行压缩工具WinRAR 5.21最新版里存在一个安全漏洞,目前该漏洞还属于零日漏 ...
- Python学习(六) —— 函数
一.函数的定义和调用 为什么要用函数:例如,计算一个数据的长度,可以用一段代码实现,每次需要计算数据的长度都可以用这段代码,如果是一段代码,可读性差,重复代码多: 但是如果把这段代码封装成一个函数,用 ...
- 修改注册表.exe的文件目录
文件打开方式不能选择默认打开文件 cmd >regedit 以sublime_text为例 HKEY_CLASSES_ROOT/Applications/sublime_text.exe/she ...
- 51Nod1518 稳定多米诺覆盖 动态规划 插头dp 容斥原理
原文链接https://www.cnblogs.com/zhouzhendong/p/51Nod1518.html 题目传送门 - 51Nod1518 题意 51Nod真是个好OJ ,题意概括的真好, ...