CSU 1326: The contest(分组背包)】的更多相关文章

http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1326 题意: n个题目,每个题目都有一个价值Pi和相对能力消耗Wi,但是有些题目因为太坑不能同时做出来,并且坑题具有传递性.(a和b一起做会坑.b和c会坑则a和c也会坑) 它们最多可以作出多少价值的题目. 分析:先用并查集,将组分出来,然后进行分组背包 注意F数组,数组开辟的大小应该为总价值的最大值,还有初始化别忘记了 以及j-pi[i]>=0一维数组: #include<stdio.h>…
裸的   并查集  +  分组背包: #include<iostream> #include<cstring> #include<algorithm> #include<stdio.h> #include<cmath> #include<vector> using namespace std; vector<]; vector<]; ],N,M,W,wi[],pi[],dp[]; int find( int x ){ if…
ACboy needs your help Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5872    Accepted Submission(s): 3196 Problem Description ACboy has N courses this term, and he plans to spend at most M days…
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1326 题意:…… 思路:并查集建图处理出边,然后分组背包. 之前不会分组背包,比赛的时候也推不出来,不知道互斥的情况怎么搞.原来就和01背包差不多,只不过是把每个组当作一个物品,然后枚举容量的时候,加上内层枚举组内的物品.注意第三层枚举组内物品要写在容量的内层,才能满足组内最多选一个的互斥条件.这里分析的挺好的:http://www.cppblog.com/Onway/archive/2010/…
Outing Input Output Sample Input 4 4 1 2 3 4 Sample Output 4 分组背包: for 所有的组k for v=V..0 for 所有的i属于组k f[v]=max{f[v],f[v-c[i]]+w[i]} 有一辆能载客m的车,有n个人,然后第i个人上车的条件是第a[i]个人要上车,问最多能上几个. 显然,一个连通块至多含有一个环.每一块的价值范围在[环点,块点]之间,将每一块视为一组,从每组的范围中任取一值,组成不超过m的最大值.因此可转换…
I love sneakers! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4464    Accepted Submission(s): 1824 Problem Description After months of hard working, Iserlohn finally wins awesome amount of sc…
ACboy needs your help Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4912    Accepted Submission(s): 2651 Problem Description ACboy has N courses this term, and he plans to spend at most M days…
AreYouBusy Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3985    Accepted Submission(s): 1580 Problem Description Happy New Term!As having become a junior, xiaoA recognizes that there is not m…
I love sneakers! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4602    Accepted Submission(s): 1893 Problem Description After months of hard working, Iserlohn finally wins awesome amount of s…
AreYouBusy Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description Happy New Term!As having become a junior, xiaoA recognizes that there is not much time for her to AC problems, because there are some o…