CF1250B.The Feast and the Bus
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Employees of JebTrains are on their way to celebrate the 256-th day of the year! There are n employees and k teams in JebTrains. Each employee is a member of some (exactly one) team. All teams are numbered from 1 to k. You are given an array of numbers t1,t2,…,tn where ti is the i-th employee's team number.
JebTrains is going to rent a single bus to get employees to the feast. The bus will take one or more rides. A bus can pick up an entire team or two entire teams. If three or more teams take a ride together they may start a new project which is considered unacceptable. It's prohibited to split a team, so all members of a team should take the same ride.
It is possible to rent a bus of any capacity s. Such a bus can take up to s people on a single ride. The total cost of the rent is equal to s⋅r burles where r is the number of rides. Note that it's impossible to rent two or more buses.
Help JebTrains to calculate the minimum cost of the rent, required to get all employees to the feast, fulfilling all the conditions above.
JebTrains 公司的员工正前往庆祝一年中的第 256 天!JebTrains 共有 n 名员工和 k 个团队。每名员工恰好属于一个团队。所有团队编号为 1 至 k。给定一个数组 t1,t2,…,tn,其中 ti 表示第 i 名员工所属的团队编号。
JebTrains 将租用一辆公交车将所有员工送往庆典现场。该公交车将进行一次或多次行程。每次行程可搭载整个团队,或恰好两个完整团队;若一次行程中搭载了三个或更多团队,则可能引发新项目,这是不允许的。此外,禁止拆分团队,即同一团队的所有成员必须乘坐同一趟行程。
可以租用容量为任意整数 s 的公交车。这样的公交车单次行程最多可搭载 s 人。租车总费用为 s⋅r 卢布,其中 r 是行程总次数。注意:不允许租用两辆或更多公交车。
请帮助 JebTrains 计算满足上述所有条件、将全部员工运送到庆典现场所需的最小租车费用。
输入格式
The first line contains two integers n and k (1≤n≤5⋅105,1≤k≤8000) — the number of employees and the number of teams in JebTrains. The second line contains a sequence of integers t1,t2,…,tn, where ti (1≤ti≤k) is the i-th employee's team number. Every team contains at least one employee.
第一行包含两个整数 n 和 k(1≤n≤5⋅105,1≤k≤8000)—— 分别表示 JebTrains 公司的员工总数和团队总数。
第二行包含一个整数序列 t1,t2,…,tn,其中 ti(1≤ti≤k)表示第 i 位员工所属的团队编号。每个团队至少包含一名员工。
输出格式
Print the minimum cost of the rent.
输出租金的最小成本。
输入输出样例
输入#1
6 3 3 1 2 3 2 3
输出#1
6
输入#2
10 1 1 1 1 1 1 1 1 1 1 1
输出#2
10
输入#3
12 4 1 2 3 1 2 3 4 1 2 1 2 1
输出#3
12
输入解题思路,AI测评打分。不知道怎么写?