Naptime Time Limit: 1000MS Memory Limit: 65536K Total Submissions:3374 Accepted: 1281 Description Goneril is a very sleep-deprived cow. Her day is partitioned into N (3 <= N <= 3,830) equal time periods but she can spend only B (2 <= B < N…
这个题目的状态还是比较好想的,dp[i][j]表示已经睡了i个时段,最后睡在j时段的最优值,但是需要处理环的情况,我的做法是算两次,第一次不处理环,第二次强制性要求第一个时段需要睡,然后查看dp[m][n]+a[1]的值是否更优. #include <iostream> #include <cstdio> #include <cstring> using namespace std; const int maxn=4e3+9; int a[maxn],dp[maxn][…
题目大意:给定一个由 N 个点组成的环,点有点权,现从中选出 M 个点,对于顺时针方向来说,每一段被选取的第一个点的点权不计入答案贡献,求选出的最大权值是多少. 题解:首先考虑线性的情况,设 \(dp[i][j][0/1]\) 表示前 i 个点选择了 j 个点,且第 i 个点是否被选择的最优解.既然是线性,则第一个点被选取的话,一定不计入答案贡献,因此初始化为:\(dp[1][1][1]=dp[1][0][0]=0\).再把环对答案的贡献考虑进去,发现只有第 1 个点被选中,且权值计入答案中这种…
题目描述 Goneril is a very sleep-deprived cow. Her day is partitioned into N (3 <= N <= 3,830) equal time periods but she can spend only B (2 <= B < N) not necessarily contiguous periods in bed. Due to her bovine hormone levels, each period has it…