无限背包dp.. 因为题目中说至少到 H 磅 , 我就直接把 H * 2 了.. -------------------------------------------------------------------------- #include<cstdio> #include<algorithm> #include<cstring> #include<iostream> #define rep( i , n ) for( int i = 0 ; i…
-------------------------------------------------------------------- #include<cstdio> #include<algorithm> #include<iostream> #include<cstring> #define rep( i , n ) for( int i = 0 ; i < n ; ++i ) #define clr( x , c ) memset( x…
Hay For Sale 购买干草 bzoj-1606 Usaco-2008 Dec 题目大意:约翰遭受了重大的损失:蟑螂吃掉了他所有的干草,留下一群饥饿的牛.他乘着容量为C(1≤C≤50000)个单位的马车,去顿因家买一些干草. 顿因有H(1≤H≤5000)包干草,每一包都有它的体积Vi(l≤Vi≤C).约翰只能整包购买,他最多可以运回多少体积的干草呢? 想法:傻逼背包裸题,直接01背包即可. 最后,附上丑陋的代码... ... #include <iostream> #include &…
描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1606 价值和重量相等的01背包问题. 分析 ... #include <bits/stdc++.h> using namespace std; +,maxn=+; int n,W; int w[maxn],dp[maxw]; int main(){ scanf("%d%d",&W,&n); ;i<=n;i++) scanf("%d&quo…
状压dp dp( x , S ) 表示最后一个是 x , 当前选的奶牛集合为 S , 则状态转移方程 : dp( x , S ) = Σ dp( i , S - { i } ) ( i ∈ S , abs( h[ i ] - h[ x ] ) > k ) ------------------------------------------------------------------------------------------- #include<cstdio> #includ…
线段树.. --------------------------------------------------------------------------------- #include<cstdio> #include<algorithm> #include<cstring> #include<iostream> #define rep( i , n ) for( int i = 0 ; i < n ; ++i ) #define clr(…
题目 1619: [Usaco2008 Nov]Guarding the Farm 保卫牧场 Time Limit: 5 Sec Memory Limit: 64 MB Submit: 491 Solved: 218 [Submit][Status] Description The farm has many hills upon which Farmer John would like to place guards to ensure the safety of his valuable…
1619: [Usaco2008 Nov]Guarding the Farm 保卫牧场 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 498 Solved: 223[Submit][Status] Description The farm has many hills upon which Farmer John would like to place guards to ensure the safety of his valuable milk…
1620: [Usaco2008 Nov]Time Management 时间管理 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 506 Solved: 306[Submit][Status] Description Ever the maturing businessman, Farmer John realizes that he must manage his time effectively. He has N jobs convenien…