编程介的小学生 2020-01-27 21:48 采纳率: 20.5%
浏览 106

The Team of ACM/ICPC

Problem Description
There are 3 people in a team of ACM/ICPC. Every member of the team will occasionally make some mistakes in the contest. So Mr.F tests every one and everybody gets a Mistake Value x. If the Mistake Values of the 3 members of a team are respectively a, b, c, then the Mistake Value of the team is m = min{ |a-b|, |b-c|, |c-a| }.
Your job is to find the best plan to minimize M which is the sum of all the Mistake Value of teams.

Input
In the first line, there are two integers N and K. N is the number of people who will make teams and K is the number of teams which is supposed to make. (3<= N <=100000) (0<= k <= N/3 )
There are N lines followed. Each line has an integer D, which is the Mistake Value of the person.(0<=D<=1000000000)

Output
Print the minimal M in one line.

Sample Input
7 2
1
5
3
2
4
7
9

Sample Output
2

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 武汉岩海低应变分析软件,导数据库里不显示波形图
    • ¥15 CreateBitmapFromWicBitmap内存释放问题。
    • ¥30 win c++ socket
    • ¥15 CanMv K210开发板实现功能
    • ¥15 C# datagridview 栏位进度
    • ¥15 vue3页面el-table页面数据过多
    • ¥100 vue3中融入gRPC-web
    • ¥15 kali环境运行volatility分析android内存文件,缺profile
    • ¥15 写uniapp时遇到的问题
    • ¥15 vs 2008 安装遇到问题