2012年7月27日

摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2844求的是能买多少种价钱的物品,多重背包教主很经典的男人八题之一。。。不过据说原题要用单调队列优化,这个二进制优化就过了。。。View Code #include <iostream>using namespace std ;int V ;int dp[100001] ;void ZeroOnePack(int c,int w){ for(int i=V;i>=c;i--) dp[i]=max(dp[i],dp[i-c]+w) ; return ;}void CompletePac... 阅读全文
posted @ 2012-07-27 16:08 LegendaryAC 阅读(260) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1059基础的二进制优化的多重背包View Code #include <iostream>using namespace std ;int V ;int dp[200001] ;void ZeroOnePack(int c,int w){ for(int i=V;i>=c;i--) dp[i]=max(dp[i],dp[i-c]+w) ; return ;}void CompletePack(int c,int w){ for(int i=c;i<=V;i++) ... 阅读全文
posted @ 2012-07-27 15:10 LegendaryAC 阅读(143) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1702G++交,基本stl栈和队列操作View Code #include <iostream>#include <stack>#include <queue>using namespace std ;int main(){ int t ; scanf("%d",&t) ; while(t--) { int n,m ; string str ; cin >> n >> str ; if(str=="FIFO&qu 阅读全文
posted @ 2012-07-27 14:05 LegendaryAC 阅读(254) 评论(0) 推荐(0) 编辑
 
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=4314dp,dp[i][j]表示i个小矮人能逃出去j个时需要之前井中剩下的人的最小a高度之和转移方程dp[i][j]=min(dp[i-1][j]-kk[i-1].a,max(dp[i-1][j-1],h-sumA[i-1]-kk[i-1].b))最神的是解题报告直接把a+b排了个序(a+b最小的先逃脱),这个自己没看出来。。。View Code #include <iostream>#include <algorithm>using namespace std ;const int 阅读全文
posted @ 2012-07-27 11:59 LegendaryAC 阅读(320) 评论(0) 推荐(0) 编辑