HUST Monthly 2011.06.26 (Personal Contest)

From: 2011-06-26 14:30:00 To: 2011-06-26 17:30:00 Now: 2017-09-22 06:52:55 Status: Public

B - Tobor and Gadgets

Time Limit: 1s Memory Limit: 128MB

Submissions: 152 Solved: 10
Description

         After Tobor’s first version’s developing, Y.D.I has a long time to share life, but it’s boring that Tobor is a camera instead of a robot with the only ability of looking, so Y.D.I has to set up M arms for Tobor, that at least, she can pick stuff up and put them down.

         There are N two-end gadgets in Y.D.I’s lab, and every gadget has a unique number on it, each is placed in a slot, and stand in a line. They can be connected together with two gadgets of adjacent number. For example, gadget of 3 can be connected with gadget of 2, and it can also connected with 2 while the other end connected with gadget of 4.

         Note, two gadgets is considered connected iff they are positioned in correct places, that gadget i positionedleft next to gadget i+1. For example: if gadget 1 is positioned left next to gadget 2, then gadget 1 and 2 are considered connected.

         Tobor is a kind robot, and she want to repay Y.D.I for his hard working, so she want to connect the N gadgets up. Every time she can pick up any number, an non-negative integer which is less than or equal to the number of Tobor’s arm – M, of gadgets from their slot, and put down them all in any empty slot. She want to connect these all gadgets in minimum time, Can you help her?

Input

Multiple case, you need process to EOF. First line of each case contains N and M, where N indicates the number of gadgets in Y.D.I’s lab, and M indicates the number of Tobor’s arm, 1 < N <= 50000, 0 < M <= 6. Next line has N non-negative 32-bit integers, split with single space.

Output

Print case number first. Print “Yes” for a success connecting of all N gadgets, “No” otherwise. If these N gadgets can be connected together, print an integer which indicates the minimum times of Tobor must do. No blank lines between cases. See Sample Output.

Sample Input
3 2
1 3 2
Sample Output
Case 1:
Yes
1
Hint

 

For more information, please download the problems in zip or pdf.

Any question please mail to dy0013@163.com.

Source
idy0013@gmail.com