HDOJ 3669 Cross the Wall, hdoj3669

Source: Internet
Author: User

HDOJ 3669 Cross the Wall, hdoj3669


Slope optimization DP...

Sort the values in the ascending order of w and h.

Dp [now] [I] = min (dp [pre] [j] + W [j + 1] * H [I]) k-1 <= j <= I-1

Maintains a convex curve and optimizes the slope.



Cross the Wall Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 327680/327680 K (Java/Others)
Total Submission (s): 4340 Accepted Submission (s): 787


Problem Description "Your SS the Great Wall, we can reach every corner in the world !" Now the citizens of Rectland want to cross the Great Wall.
The Great Wall is a huge wall with infinite width and height, so the only way to cross is to dig holes in it. all people in Rectland can be considered as rectangles with varying width and height, and they can only dig rectangle holes in the wall. A person can pass through a hole, if and only if the person's width and height is no more than the hole's width and height both. to dig a hole with width W and height H, the people shoshould pay W * H dollars. please note that it is only permitted to dig at most K holes for security consideration, and different holes cannot overlap each other in the Great Wall. remember when they pass through the wall, they must have their feet landed on the ground.
Given all the persons 'width and height, you are requested to find out the minimum cost for digging holes to make all the persons pass through the wall.
 
InputThere are several test cases. the first line of each case contains two numbers, N (1 <= N <= 50000) and K (1 <= K <= 100 ), indicating the number of people and the maximum holes allowed to dig. then N lines followed, each contains two integers wi and hi (1 <= wi, hi <= 1000000), indicating the width and height of each person.
OutputOutput one line for each test case, indicates the minimum cost.

 
Sample Input
2 11 100100 12 21 100100 1
 
Sample Output
10000200
 
Source2010 Asia Regional Harbin







Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.