306770: CF1250B. The Feast and the Bus

Memory Limit:512 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

The Feast and the Bus

题意翻译

## 题目描述 某公司的员工们要庆祝今天的第$256$天!该公司有$n$名员工和$k$个团队,每个员工仅属于$1$个团队,每个团队至少有$1$名员工。团队编号从$1$到$k$。现在给出$n$个数字:$t_1,t_2,……t_n$,$t_i$表示第$i$个员工属于第$t_i$个团队。该公司雇佣了一辆班车,这辆班车将会往返多次承载员工去参加宴会,每一次可以承载$1$个团队或者$2$个团队,且每一个团队不能分离,必须在同一次车上。这辆车可以承载$s$个员工,$s$可以为任意值,假设通过$r$次运输,所有的员工都到达宴会目的地了,该公司需要支付$s*r$元(只有$1$辆班车)。现在要你计算$r*s$的最小值。 ## 输入格式 第一行为两个整数$n$和$k$。$(1<=n<=5*10^5,1<=k<=8000)$ 第二行为$n$个整数:$t_1,t_2……t_n$。 ## 输出格式 请输出一个整数,表示最小花费。

题目描述

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 $ t_1, t_2, \dots, t_n $ where $ t_i $ 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 \cdot 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.

输入输出格式

输入格式


The first line contains two integers $ n $ and $ k $ ( $ 1 \le n \le 5\cdot10^5, 1 \le k \le 8000 $ ) — the number of employees and the number of teams in JebTrains. The second line contains a sequence of integers $ t_1, t_2, \dots, t_n $ , where $ t_i $ ( $ 1 \le t_i \le k $ ) is the $ i $ -th employee's team number. Every team contains at least one employee.

输出格式


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

Input

题意翻译

## 题目描述 某公司的员工们要庆祝今天的第$256$天!该公司有$n$名员工和$k$个团队,每个员工仅属于$1$个团队,每个团队至少有$1$名员工。团队编号从$1$到$k$。现在给出$n$个数字:$t_1,t_2,……t_n$,$t_i$表示第$i$个员工属于第$t_i$个团队。该公司雇佣了一辆班车,这辆班车将会往返多次承载员工去参加宴会,每一次可以承载$1$个团队或者$2$个团队,且每一个团队不能分离,必须在同一次车上。这辆车可以承载$s$个员工,$s$可以为任意值,假设通过$r$次运输,所有的员工都到达宴会目的地了,该公司需要支付$s*r$元(只有$1$辆班车)。现在要你计算$r*s$的最小值。 ## 输入格式 第一行为两个整数$n$和$k$。$(1<=n<=5*10^5,1<=k<=8000)$ 第二行为$n$个整数:$t_1,t_2……t_n$。 ## 输出格式 请输出一个整数,表示最小花费。

加入题单

上一题 下一题 算法标签: