codeforces723C Polycarp at the Radio 英语阅读题

告别云端推理!用llama.cpp+树莓派5搭建本地AI问答机器人(完整配置流程) 本文详细介绍了如何在树莓派5上利用llama.cpp部署本地AI问答机器人,实现完全离线的智能对话。通过模型量化与格式转换技术,成功将MiniCPM-2B等大模型压缩并运行于资源受限的边缘设备,解决了隐私、延迟和成本问题,为物联网和硬件开发者提供了完整的配置流程与实践指南。 阅读详情

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;
}







电容放电测试解析 电子设备断电后滤波电容残留电荷存在触电风险,需符合IEC等安全标准对放电时间的要求。放电测试需测量电容电压下降至安全值的时间,设计可采用主动放电电路或被动放电电阻。常见问题包括电阻选择不当或电路设计缺陷,建议预留放电时间裕度并采用组合放电方案。合规的放电设计是确保产品安全性和可靠性的关键环节。 阅读详情

相关推荐

从零开始掌握RDMA拥塞控制:原理、算法与实战解析

本文深入解析了RDMA拥塞控制的核心原理与实战配置。RDMA依赖无损网络保障高性能,其关键在于PFC与ECN两大技术协同防止丢包。文章重点剖析了主流算法DCQCN的工作机制与参数调优,并简要介绍了HPCC与TIMELY等前沿算法。最后提供了在Linux上配置RoCEv2与DCQCN的详细步骤及性能调试方法,帮助读者从零构建稳定的RDMA网络环境。

weixin_28452161的博客 141

[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

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

(超详细)Scala环境搭建(scala-2.12.15、IDEA2021.1.3)

Scala环境搭建(scala-2.12.15、IDEA2021.1.3) JunLeon——go big or go home 目录 Scala环境搭建(scala-2.12.15、IDEA2021.1.3) 一、Scala概述 1、什么是Scala? 2、Scala发展史 3、Scala与Java的关系 二、Scala环境搭建 1、环境准备 2、Scala安装与配置环境变量 3、验证Scala 三、编写第一个Scala程序 1、使用IDEA创建maven工程 2、.

JunLeon的博客 3万+

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的博客 278

Linux下XDMA驱动调试实战:从PCIe枚举到DMA性能调优

PCIe枚举是设备与主机通信的基础,涉及BAR空间映射和配置空间访问。XDMA作为Xilinx的PCIe DMA IP核,其驱动probe流程和DMA描述符机制直接影响数据传输效率。在FPGA加速卡和数据采集卡等场景中,掌握XDMA调试技巧能显著提升系统稳定性和吞吐量。本文围绕PCIe枚举、BAR映射、DMA描述符、MSI-X中断等关键环节,深入剖析Linux环境下XDMA驱动的常见问题与性能调优方法,帮助工程师快速定位硬件链路、IP配置及驱动层的故障。

weixin_29171129的博客 220

Silvaco Atlas(五)——物理模型总结

物理模型总结

qsz1425AWD2121的博客 2161

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 674

别再手动算考勤了!教你用Python+企业微信API自动生成月度报表

本文介绍如何利用Python和企业微信API构建自动化考勤分析系统,实现从数据获取到可视化报表生成的全流程自动化。通过企业微信打卡接口获取数据,使用Pandas进行高效清洗和分析,并生成Excel和HTML格式的报表,大幅提升考勤统计效率。系统支持智能判定考勤状态,如迟到、早退等,并可通过定时任务实现月度自动化运行。

weixin_27875131的博客 301

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

分立器件高压放大电路设计:从SMU前级到四象限模块的实操指南

在精密测试设备中,高压放大电路常面临集成运放电压受限、成本高、供货难等问题。其原理基于差分输入级、中间增益级和推挽输出级的三级结构,通过合理补偿与器件选型实现高压输出。技术价值在于灵活控制工作点、提升耐压与线性度,并支持四象限工作。典型应用于SMU前级、压电驱动等场景。本文围绕分立器件、高压放大电路、运放和SMU,分享从架构搭建、参数计算到调试避坑的完整工程实践。

weixin_29181861的博客 120

麒麟V10 SP3国产化环境部署MySQL 8.0全流程实战

本文详细介绍了在国产化操作系统麒麟V10 SP3上部署MySQL 8.0的全流程实战指南。从环境准备、冲突排查到安装包处理、服务配置与安全加固,提供了详细的命令和技巧,帮助用户顺利完成MySQL 8.0的部署与优化,适用于国产化环境下的数据库应用。

weixin_29231027的博客 280

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

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

Regina8023 1115

用Python爬取公众号历史所有文章,看这篇就够了

手把手教你爬取公众号历史所有文章

u010522887的专栏 1万+

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的博客 683

IMSL CNL 7.0.0 (x86-64)Crack

IMSL CNL 7.0.0 (x86-64)Crack intel的算法库破解文件,这是C++版本的破解文件

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

【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

楚江枫 962

InTheHand.Net.Personal+BlueTooth4,蓝牙开发

项目中有蓝牙开发的必备dll,现在网上相关的文档博客不少,有的说的多有的说少,但是却很少有这两个dll,分享一下。

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

一只小蒟蒻的博客 1305

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

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 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的博客 714

【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的博客 634

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的博客 267

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

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 [模拟]【杂类】

题目链接: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

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的博客 647

【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

魔笛手的博客 824

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
上一篇: 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、付费专栏及课程。

余额充值
⌂ 换网址