| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
55用了楼大叔PPT的方法,多重背包化0-1和bitset,还是超(代码)O(NMlgC)
bitset<100010> dp[2];//做滚动数组
v[], vp //做物品代价数组和尾指针
是不是这部分还有什么能挖的?
for(int i=0; i<vp; i++)
{
x=i%2; y=(i+1)%2;
dp[y]=dp[x];
for(int j=v[i]; j<=m; j++)
if(!dp[y][j] && dp[x][j-v[i]])
dp[y].set(j);
}
输出dp[y].count()-1
答案是没错的
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator