HDU 3669 Cross the Wall】的更多相关文章

题目连接:hdu 3669 Cross the Wall 题意: 现在有一面无限大的墙,现在有n个人,每个人都能看成一个矩形,宽是w,高是h,现在这n个人要通过这面墙,现在只能让你挖k个洞,每个洞不能重叠,每个洞需要消耗你挖的w*h,现在问你最小消耗多少. 题解: 设dp[i][j]为前j个人挖i个洞的最小消耗. 首先我们先将每个人按w排序,我们可以发现,排序后的h是递减的,因为如果不是递减的,可以把那个点消掉,因为w[k]<w[j]&&h[k]<h[j]的话,那么第k个人就可…
首先要感谢叉姐的指导Orz 这一类问题的DP方程都有如下形式 dp[i] = w(i) + max/min(a(i)*b(j) + c(j)) ( 0 <= j < i ) 其中,b, c均为j的单调函数.通常情况下a(i)也是单调的,a(i)不单调时就只能二分查找了. 这里讲一下当c(j)单调递增,b(j)单调递减,原方程求min的情况 对于同一j,b(j),c(j)为常数,而a(i)为变量,令y = b(j) * x + c(j),则y为线性函数 我们把( 0 <= j < i…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3669 题目大意:有n(n<=50000)个矩形,每个矩形都有高和宽,你可以在墙上最多挖k个洞使得可以通过,问你最小花费(所有挖的洞的h*w之和)是多少. 解题思路:先将所有矩形按宽从大到小,高从大到小,如果一个矩形宽和高都小于等于前面的矩形则肯定会被前面的矩形覆盖(完全放在前面的矩形里),那么这个矩形就可以删掉,因为不影响结果. 最后再倒序,使得宽从小到大,高从大到小,则状态转移方程为:dp[i][…
题目大意 给定 \(N\) 个矩形的宽和高, \((h_1, w_1), (h_2, w_2), \dots, (h_n w_n)\) . 现需要确定 \(k\) (\(k \le K\), \(K\) 给定) 个矩形 \((H_i, W_i)\) , 使得 \(\forall i \ (1\le i\le N), \exists j,\ s.t.\ H_j \ge h_i\) 且 \(W_j \ge w_i\), 此时称这后 \(k\) 个矩形覆盖前 \(N\) 个矩形, 代价为 \(\sum…
问题分析 首先,如果一个人的\(w\)和\(h\)均小于另一个人,那么这个人显然可以被省略.如果我们将剩下的人按\(w[i]\)递增排序,那么\(h[i]\)就是递减. 之后我们考虑DP. 我们设\(f[i][j]\)为到第\(i\)个人,打了\(j\)个洞的花费.于是我们可以得到如下DP过程: for( LL i = 1; i <= N; ++i ) F[ i ][ 1 ] = w[ i ] * h[ 1 ]; for( LL j = 2; j <= K; ++j ) for( LL i =…
Cross the Wall Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 327680/327680 K (Java/Others)Total Submission(s): 4479    Accepted Submission(s): 812 Problem Description “Across the Great Wall, we can reach every corner in the world!” Now the…
http://acm.hdu.edu.cn/showproblem.php?pid=1543 #include <cstdio> #include <cstring> #include <algorithm> #define maxn 10000 using namespace std; int h,w,n; ][],clo[maxn]; struct node { int x1,y1,x2,y2,c; }p[maxn*]; int bs(int key,int l,i…
http://acm.hdu.edu.cn/showproblem.php?pid=2124 Problem Description Long time ago , Kitty lived in a small village. The air was fresh and the scenery was very beautiful. The only thing that troubled her is the typhoon. When the typhoon came, everythin…
Paint The Wall Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3427    Accepted Submission(s): 955 Problem Description As a amateur artist, Xenocide loves painting the wall. The wall can be c…
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 327680/327680 K (Java/Others) Total Submission(s): 4619    Accepted Submission(s): 846 Problem Description "Across the Great Wall, we can reach every corner in the world!" Now the citizens…