codeforces723C Polycarp at the Radio 英语阅读题

Docker “docker login“ 失败? 登录阿里云镜像仓库仓库 unauthorized: authentication required 文章目录听说你 login fail?来,让我们解决一下!登录,撒花 听说你 login fail? 美滋滋的在服务器上安装完成Docker应用,开始配置阿里云镜像加速?然后被阿里云官方文档蹂躏?别急别急,让我来拯救你。 我们先来看看 阿里云官方文档 Docker镜像基本操作: 好家伙,emmm… 上来直接就Login Succeeded,这不简直so easy?我们也来照着操作操作: docker@default-online:~$ docker login registry.cn-hangzhou.a 阅读详情

C. Polycarp at the Radio
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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 2
1 2 3 2
output
2 1
1 2 1 2 



input
7 3
1 3 2 2 2 2 1
output
2 1
1 3 3 2 2 2 1 



input
4 4
1000000000 100 7 1000000000
output
1 4
1 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.



题干真TM难懂……a里面的元素是乐队的编号,a反映的是乐队出场次数和顺序(顺序不重要,关键是次数),也就是说一个编号在a里面出现了多少次,它就上场了多少次,b[x] = y的意思是Polycarp喜欢的乐队x出场y次,这里x是他超喜欢的乐队的名字的编号,他想要改变a使他喜欢的乐队中出演的最少次数最大,也就是说每个b[i] >= per,这个per尽可能大,什么时候per最大,当然是均值n / m的时候

有一个注意的地方就是例如:

7 3

1 3 2 4 2 2 1

7 / 3 = 2,到底是把4变成3还是把一个2变成3,其实无所谓,最后min(b[1], b[2], b[3])都是等于2,虽然把4变成3确实使喜欢的乐队总数多,但是题目要求的是最少的出场次数最大,并不是总体数目尽量多,还有就是比如变一个2为3,则成为1 3 3 4 2 2 1,还有没有必要继续变4为1,2,3其中之一?没必要,因为就算变了,min(b[1], b[2], b[3])还是为2,还白白多加了一次变换次数,题目要求出场次数最小值尽可能大的同时,还要求改变次数尽可能小


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

int n, m, per, cnt;
int a[2005];
map<int, int> mp;

int main()
{
	cin >> n >> m;
	per = n / m;
	mp.clear();
	for (int i = 1; i <= m; i++) {
		mp[i] = 0;
	}
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		if (a[i] >= 1 && a[i] <= m) {
			mp[a[i]]++;
		}
	}
	printf("%d ", per);
	cnt = 0;
	for (map<int, int>::iterator i = mp.begin(); i != mp.end(); i++) {
		if (i->second < per) {
			for (int j = 0; j < n; j++) {
				if (a[j] > m || a[j] < 1) {
					a[j] = i->first;
					i->second++;
					cnt++;
				}
				else if (mp[a[j]] > per) {
					mp[a[j]]--;
					i->second++;
					a[j] = i->first;
					cnt++;
				}
				if (i->second >= per) break;
			}
		}
	}
	printf("%d\n", cnt);
	for (int i = 0; i < n; i++) {
		printf(i == 0 ? "%d" : " %d", a[i]);
	}
	puts("");
	return 0;
}







操作系统 | 知识梳理 | 复习(上) 操作系统复习 阅读详情

相关推荐

SigmaStar(星宸科技)SSC33X系列

目前,SSC33X系列已经量产了接近两年,SDK成熟稳定,功耗表现良好,图像效果出色,广泛应用在AI枪机、AI球机、AI云台机、多目摄像机、停车场闸机、人脸门禁、人脸锁、门铃猫眼等产品上。

Comake Online的博客 1万+

[codeforces] C. Polycarp at the Radio 数组统计

C. Polycarp at the Radio time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Polycarp is a music editor at the

你那么爱笑,家里人知道吗? 808

父子Agent架构:解决AI系统上下文污染的技术方案

在AI系统设计中,上下文管理是核心挑战之一。传统单Agent架构在处理复杂任务时,常面临上下文无限膨胀导致的信息淹没和性能下降问题。父子Agent架构通过职责分离和上下文隔离机制,采用分而治之的思想,将大任务拆解为多个子任务由专门子Agent处理。该架构中父Agent负责任务规划和结果汇总,子Agent执行具体任务后立即销毁中间状态,通过精炼摘要进行通信。这种设计不仅能有效控制上下文长度,还能提升系统稳定性和执行效率,特别适用于编程辅助、自动化测试等需要多步骤处理的场景。父子Agent架构体现了计算机科学中

weixin_42531710的博客 352

Codeforces Round #690 (Div. 3) A. Favorite Sequence 模拟

Polycarp has a favorite sequence a[1…n] consisting of n integers. He wrote it out on the whiteboard as follows: he wrote the number a1 to the left side (at the beginning of the whiteboard); he wrote the number a2 to the right side (at the end of the whiteb

qq_45891413的博客 277

前馈神经网络求解XOR问题

摘要 前馈神经网络是一种最简单的神经网络,各神经元分层排列。每个神经元只与前一层的神经元相连。接收前一层的输出,并输出给下一层.各层之间没有反馈。是目前应用最广泛、发展最迅速的人工神经网络之一。研究从20世纪60年代开始,目前理论研究和实际应用达到了很高的水平[1]。本节通过设计包含输入层、一个隐含层和输出层的前馈神经网络,实现XOR运算,并基于计算数据或实验数据分析隐含层决策面的特点,进而总结前馈神经网络隐含层的作用。 1.1 神经网络结构设计 1.1.1 XOR问题描述 ...

sinat_28178805的博客 2358

人形机器人核心架构梳理

定义:机器人是能进行运动、操纵或定位且具有一定程度自主能力的可编程执行机构。按外在形态分类可分为传统机器人和人形机器人,其中人形机器人是一种利用人工智能和机器人技术制造的具有类似人类外观和行为的机器人。

小海聊智造 1万+

Codeforces 1006B - Polycarp's Practice

链接:Codeforces 1006B - Polycarp's Practice 大意:给你k天时间解决n个问题,每个问题都有一个价值。所有问题必须按顺序解决且在第k天完成。定义每天的价值为当天解决的问题的最大价值,求k天最大的总价值。(1&lt;=k&lt;=n&lt;=2000,1&lt;=ai&lt;=2000) 思路:对问题的价值排序,选出前k个问题,然后再按顺序排序,得到的序列即为...

淡泊明志,宁静致远 383

基于PWM的汽车仪表步进电机微步驱动优化实践

本文深入探讨了基于PWM的微步驱动技术,用于优化汽车仪表步进电机的运行性能。通过将传统的分步驱动升级为PWM微步细分驱动,利用正弦/余弦查表法合成旋转磁场,有效消除了指针抖动与噪声,实现了指针的平滑、精准运动。文章以STM32和VID2905电机为例,提供了详细的硬件连接、代码实现及高级优化技巧,为提升汽车仪表体验提供了实用方案。

weixin_29169505的博客 510

【codeforces 723 C】【暴力】C. Polycarp at the Radio【1~m中最少的数尽量多】

传送门:C. Polycarp at the Radio 描述: C. Polycarp at the Radio time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output

魔笛手的博客 823

手把手带你实现DAF-Net:零代码基础入门红外与可见光图像融合(从理论到实战)

本文介绍了红外与可见光图像融合技术及DAF-Net网络的应用。红外图像能捕捉热源但缺乏细节,可见光图像纹理丰富但在低光环境下表现不佳。DAF-Net采用双分支特征提取和动态注意力融合架构,能智能分配特征权重实现优势互补。文章详细讲解了环境配置、数据集准备(如TNO数据集)和预处理方法,并提供了DAF-Net的核心代码实现,包括特征提取、注意力融合和图像重建模块。通过该技术可在安防、自动驾驶等领域获得更优质的融合图像,提升视觉感知能力。

m0_71589036的博客 228

2025华为od机试真题B卷【版本管理】JavaScript实现

在 软件版本管理中,版本号由点分割的数字组成,例如 1.2.3 和 2.8。现在,你需要编写一个函数,计算两个版本号之间的可用版本号个数。这里的可用版本号指的是所有满足 version1<x<version2的版本号x的个数。若 version1 >=version2 返回0.,

MISAYAONE的博客 254

1006B Polycarp's Practice

B. Polycarp's Practice time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Polycarp is practicing his problem solving skill. He has a...

memory_qianxiao的博客 679

ProgLoss+STAL 技术详解:YOLO26 小目标检测增强方案

本文提出了一种基于ProgLoss渐进式损失函数和STAL小目标感知标签分配的YOLO26增强方案。针对小目标检测中特征信息少、正负样本不平衡等难题,STAL通过尺度感知的标签分配策略动态调整候选样本数量和IoU阈值,为小目标分配更多正样本;ProgLoss则根据训练阶段动态调整分类和回归损失的权重,早期侧重定位能力,后期加强分类精度。实验表明,该组合方案显著提升了小目标检测性能,在COCO数据集上小目标AP达到38.2%,比基线提升6.5个百分点。该方法为遥感、监控等场景的小目标检测提供了有效解决方案。

一键难忘的博客 1283

codeforces 723C. Polycarp at the Radio [模拟]【杂类】

题目链接:http://codeforces.com/contest/723/problem/C ————————————. C. Polycarp at the Radio time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output

Tabris的博客 493

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

Codeforces Round #690 (Div. 3) 题解(A-E2)

文章目录A. Favorite Sequence题目input & output题意思路代码B. Last Year's Substring题目input & output题意思路代码C. Unique Number题目input & output题意思路代码D. Add to Neighbour and Remove题目input & output题意思路代码E2. Close Tuples (hard version)题目input & output题意思路代码E

一只小蒟蒻的博客 1304

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

codeforces 727F. Polycarp's problems DP or 二分预处理答案

题目链接:http://codeforces.com/contest/727/problem/F  题目大意:有n个问题,每个问题有一个价值ai,一开始的心情值为q,每当读到一个问题时,心情值将会加上该问题的价值。问题只能按顺序读。有m个询问,求当q=bi时,至少要删去多少个问题才能使得在任何时候心情值都>=0。  数据范围:1 ≤ n ≤ 750, 1 ≤ m ≤ 200 000, - 10

AK_HuangYC的博客 709

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

codeforces723C- Polycarp at the Radio-greedy

题目大意:n个数,要求使得1到m出现的次数中的最小值要最大,问你是多少并最少要交换几次; 题目解析:首先那个数肯定是n/m,那么我们把map[i] (im并且stack不为空交换,icnt时也可以做交换; AC代码: #include #include #include #include #include #include using namespace std; stacks; int m

zyz_3_14159的博客 539

【codeforces #276(div 1)】ABD题解

codeforces #276(div 1)ABD题解+代码~

Regina8023 1110

【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 standard input output standard output Polycarp is a music editor at the

snowy_smile的博客 633

Codeforces 723C暴力(最小值最大)

点击打开链接 #include #include #include #include #include #include #include #define M 2016 using namespace std; const int inf=1<<20; int a[M],b[M];//b[j] the num of songs the groups j plays map

Masamiiiiii 671

【codeforces 723C】 + 思维

C. Polycarp at the Radio time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Polycarp is a music editor at the radio station. He received a pl

楚江枫 960

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 standard input output standard output Polycarp is a music editor

fouzhe的博客 707

CodeForces 723C Polycarp at the Radio (贪心+暴力)

题意:给定 n 个数,让把某一些变成 1-m之间的数,要改变最少,使得1-m中每个数中出现次数最少的尽量大。虽然这个贪心挺好想到的,但是却不是那么容易敲出来。。。 看别人的代码,真好。。int a[N]; int cnt[N]; int main(){ int n,m; sf("%d%d",&n,&m); int ans1=n/m,ans2=0; rep(i,1,n

now_ing的博客 266

Codeforces #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 standard input output standard output Polycarp is a music editor at the radio station. He rece

mengxiang000000 605

cf723c Polycarp at the Radio

Polycarp is a music editor at the radio station. He received a playlist for tomorrow, that can be represented as a sequencea1, a2, ..., an, whereaiis a band, which performs thei-th song. Po...

weixin_30360497的博客 197

Codeforces Round #375 (Div. 2) -- C. Polycarp at the Radio(水题)

大体题意: 给你n 个数,要求1~m每个数出现次数的最小值尽可能大,要求你修改n个数,要改的次数尽可能小,输出最小值的最大可能和最少修改次数,并把改的数组输出出来! 思路: 开始没看到次数尽可能少,wa了一次! 想一想就知道,最大可能值肯定是 n/m 那么直接统计1~m 每个数出现了几次! 然后枚举一遍a数组,如果当前值  在1~m范围内!就判断这个数的出现次数  如果小于等于n/m

aozil_yang的博客 643
上一篇: codeforces723B Text Document Analysis
下一篇: hdu1754 I Hate It
Daemoonn
博客等级 码龄11年 42粉丝 198原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值