The Karting
来源:互联网 发布:php网站数据库在哪里 编辑:程序博客网 时间:2024/05/29 06:59
The Karting
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 0 Accepted Submission(s): 0
Problem Description
The Karting championship will be held on a straight road. There are N keypoints on the road. The path between keypoint i and i+1 has a degree of difficulty Di(Di may be negative if the path is too smooth). Now the Organizers want to darw up some routes among these keypoints(The number of routes can be many to avoid a boring match). The organizers will choose some checkpoints from the keypoints for the routes(Each route shold include at least two checkpoints, and each keypoint can not be chosen as checkpoint more than once. Two routes can not share one checkpoint). The players should drive their karts to pass the checkpoints in the given order and return to the first checkpoint.
For example, if there are 4 checkpoints 1,3,2,4 in order in a route, players shold drive pass keypoint 1,2,3,2,3,4,3,2,1 in order. In this example, the players should make a 180 degree turn 4 times in the route(When players return to checkpoint 1, they also need to make a 180 degree turn). Makeing a 180 degree turn also has a degree of difficulty D0. The difficulty of a route is defined as follow. The initial difficluty is 0. Each time the players in the route need to pass the path between keypoint i and i+1, the difficulty shold increase Di, and each time the players need to make a 180 degree turn, the difficulty should increase D0.
To make the championship more exciting, the organizers want to maximize the sum of difficulty of all routes. They will choose exactly M keypoints to set up checkpoints. So what is the maximum sum of difficulty of all routes?
For example, if there are 4 checkpoints 1,3,2,4 in order in a route, players shold drive pass keypoint 1,2,3,2,3,4,3,2,1 in order. In this example, the players should make a 180 degree turn 4 times in the route(When players return to checkpoint 1, they also need to make a 180 degree turn). Makeing a 180 degree turn also has a degree of difficulty D0. The difficulty of a route is defined as follow. The initial difficluty is 0. Each time the players in the route need to pass the path between keypoint i and i+1, the difficulty shold increase Di, and each time the players need to make a 180 degree turn, the difficulty should increase D0.
To make the championship more exciting, the organizers want to maximize the sum of difficulty of all routes. They will choose exactly M keypoints to set up checkpoints. So what is the maximum sum of difficulty of all routes?
Input
There are multiple test cases.
The first line of each test case contains two integers N and M(2<=M<=N<=100).
The second line contains N integers D0,D1,D2,...,Dn-1(-100<=Di<=100).
The first line of each test case contains two integers N and M(2<=M<=N<=100).
The second line contains N integers D0,D1,D2,...,Dn-1(-100<=Di<=100).
Output
One integer in a single line for each test case, the maximum sum of difficulty of all routes.
Sample Input
4 21 1 1 -1
Sample Output
6
阅读全文
0 0
- The Karting
- Hdu 6157 The Karting 多维DP
- 8月19号CCPC——The Karting(未解决)
- The hell--The hope
- the Denser the Better ?
- the CComSingleThreadModel & the CComMultiThreadModel
- The more, The Better
- the+比较级,the+比较级
- The more, The Better
- The more, The Better
- the good,the bad ,the ugly
- The First!
- The Beginning
- The matrix
- The Singer
- The Makefile
- The thief
- The scrolls
- (二)SSM中mybatis一对一查询
- 服务器开发之简单的TCP回射服务器(0):程序说明
- Palindrome Function
- instanceof的使用: 对象与构造函数在原型链上是否有关系
- 交换排序-冒泡排序
- The Karting
- hdu2955(01背包)
- The Designer
- 笔记
- [2017-08-19 17:02:13
- HTTP状态码详解
- POJ 3233Matrix Power Series
- Floyd算法学习(最短路径)
- Graph Of Zhuper