ACQUIRE - Land Acquisition

题意翻译

## 题目大意 约翰准备扩大他的农场,眼下必须购买 N 块长方形的土地。如果约翰单买一块土地,价格就是土地的面积。他也可以选择并购一组土地,并购的价格为这些土地中最大的长乘以最大的宽。 比如约翰并购一块 3 × 5 和一块 5 × 3 的土地,他只需要支付 5 × 5 = 25 元,比分开买合算。 约翰发现,将这些土地分成不同的小组来并购可以节省经费。给定每份土地的尺寸,请你帮助他计算购买所有土地所需的最小费用。 ### 输入格式 - 第一行:单个整数 N, 1 ≤ N ≤ 50000 - 第二行到第 N + 1 行:第 i + 1 行有两个整数 Hi 和 Wi, 1 ≤ Hi; Wi ≤ 106 ### 输出格式 - 单个整数:购买所有土地的最小费用 #### 样例输入 4 100 1 15 15 20 5 1 100 #### 样例输出 500 ### 解释: >分三组:第一组 100 × 1,第二组 1 × 100, 第三组是 20 × 5 和 15 × 15,价格分别为 100、100 和 300

题目描述

``` <pre style="font-family: 'Andale Mono', 'Courier New', Courier, monospace;">``` ********************************************************************** GOLD PROBLEMS ********************************************************************** Three problems numbered 1 through 3 ********************************************************************** Problem 1: Land Acquisition [Paul Christiano, 2007] Farmer John is considering buying more land for the farm and has his eye on N (1 <= N <= 50,000) additional rectangular plots, each with integer dimensions (1 <= width_i <= 1,000,000; 1 <= length_i <= 1,000,000). If FJ wants to buy a single piece of land, the cost is $1/square unit, but savings are available for large purchases. He can buy any number of plots of land for a price in dollars that is the width of the widest plot times the length of the longest plot. Of course, land plots cannot be rotated, i.e., if Farmer John buys a 3x5 plot and a 5x3 plot in a group, he will pay 5x5=25. FJ wants to grow his farm as much as possible and desires all the plots of land. Being both clever and frugal, it dawns on him that he can purchase the land in successive groups, cleverly minimizing the total cost by grouping various plots that have advantageous width or length values. Given the number of plots for sale and the dimensions of each, determine the minimum amount for which Farmer John can purchase all PROBLEM NAME: acquire INPUT FORMAT: * Line 1: A single integer: N * Lines 2..N+1: Line i+1 describes plot i with two space-separated integers: width_i and length_i SAMPLE INPUT: 4 100 1 15 15 20 5 1 100 INPUT DETAILS: There are four plots for sale with dimensions as shown. OUTPUT FORMAT: * Line 1: The minimum amount necessary to buy all the plots. SAMPLE OUTPUT: 500 OUTPUT DETAILS: The first group contains a 100x1 plot and costs 100. The next group contains a 1x100 plot and costs 100. The last group contains both the 20x5 plot and the 15x15 plot and costs 300. The total cost is 500, which is minimal. ``` ```

输入输出格式

输入格式


输出格式


输入输出样例

暂无测试点