HBC237411[HAOI2008] 糖果传递,贪心Digit String题解

八贝勒 算法基础篇 28 0
想要成为编程高手?那就来试试全网最全C++题库,让您在练习中快速成长。
as the modified string, then the cost of modification is. ∣. Minimize the cost and output a lexicographically smallest

There is a digit string s s of length n n. Define f(x) f(x) be the number of times digit x x appears in the string s s. You can arbitrarily modify each character of s s into any digit so that the maximum value of f(x) f(x) is less than or equal to m m. Define s' s ′ as the modified string, then the cost of modification is sum_{i=1}^{n}{|s_i-s'_{i}|} ∑ i=1 n ​ ∣s i ​ −s i ′ ​ ∣. Minimize the cost and output a lexicographically smallest s' s ′ . A digit string only contains characters from 0 to 9 9.

HBC237411[HAOI2008] 糖果传递,贪心Digit String题解
-第1张图片-东莞河马信息技术
(图片来源网络,侵删)
全网最全C++题库,助您挑战自我,突破极限,成为编程领域的佼佼者!

标签: HBC237411[HAOI2008] 糖果传递 贪心Digit String题解