[Codeforces 115E]Linear Kingdom Races】的更多相关文章

题目大意: 有n块地,初始是荒地.你可以把某些荒地开垦(需要花费相应的价值\(a_i\)(正整数)),然后这些荒地就可以种田. 现在有m年,每年要在l到r区间内种田,获得p(正整数)的价值(必须保证l~r都已经开荒,否则不能种田). 问最大收益. 解题思路: DP. 设F[i][j]表示前i块地,最后有连续的j块地已开荒的最大收益. 则\(F[i+1][0]=max\{F[i][j]\}\).不开荒,则中间断了,所以连续的值只有0了. F[i+1][j+1]=F[i][j]-a[i]+v.开荒,…
[CF115E]Linear Kingdom Races 题目大意: 有\(n(n\le10^5)\)个物品,编号为\(1\sim n\).选取第\(i\)个物品需要\(c_i\)的代价.另外有\(m(m\le10^5)\)个条件,表示若\(l_i\sim r_i\)间的物品全部选择,可以获得\(p_i\)的收益.求最大收益. 思路: 用\(f[i]\)表示考虑完前\(i\)个物品是否选取能获得的最大收益. 转移方程为\(f[i]=\max\{f[j]-\texttt{cost}(j+1,i)+…
大意: n条赛道, 初始全坏, 修复第$i$条花费$a_i$, m场比赛, 第$i$场比赛需要占用$[l_i,r_i]$的所有赛道, 收益为$w_i$, 求一个比赛方案使得收益最大. 设$dp[i]$为只考虑前$i$条赛道的最大收益, $calc(i,j)$为占用区间$[i,j]$的赛道的比赛收益和, $s$为$a$的前缀和, 有 $$dp[i]=\max\limits_{1\le j < i}(dp[j]+calc(j+1,i)+s[j])-s[i]$$ $calc$的贡献用线段树更新即可,…
pro: 从左到有有N个车道,都有一定程度损坏,所以有不同的修理费a[]: 有M场比赛,每场比赛的场地是[Li,Ri],即如果这个区间的车道都被修理好,则可以举办这个比赛,并且收益是Pi.问最多得到多少收益.N,M<2e5: sol: 比较明显的右端点排序,求最大DP问题.  dp[i]表示只考虑修前i条路的最大收益,那么dp[i]=max(dp[j]+P(j+1,i)-a(j+1,i)); P(i,j)表示这个区间的收益,a(i,j)表示这个区间的修理费. 考虑无后效性,我们按右端点排序,然后…
前言:前辈讲课时设的状态还是有些繁琐,感觉题解设的状态更简洁. -------------- 题目链接 题目大意:给定$n$条道路和$m$场比赛,每个道路修建需要$c_i$,每场比赛需要使用$[l_i,r_i]$内的道路,收益为$p_i$.问最大收益.$n,m\leq 200000$ 先将所有的区间右端点从小到大排序. 设$f[i][j]$表示已经考虑前$i$条道路,最右边没有修的道路是$j$.现在考虑转移. 如果不修第$i$条道路,那么最右边的没有修的道路就变成$i$了.有这样的方程$f[i]…
Description Meanwhile, the kingdom of K is getting ready for the marriage of the King's daughter. However, in order not to lose face in front of the relatives, the King should first finish reforms in his kingdom. As the King can not wait for his daug…
Long time ago, there was a great kingdom and it was being ruled by The Great Arya and Pari The Great. These two had some problems about the numbers they like, so they decided to divide the great kingdom between themselves. The great kingdom consisted…
Meanwhile, the kingdom of K is getting ready for the marriage of the King's daughter. However, in order not to lose face in front of the relatives, the King should first finish reforms in his kingdom. As the King can not wait for his daughter's marri…
题意:给你m条边,每条边有一个权值,每次询问只保留编号l到r的边,让你把这个图分成两部分 一个方案的耗费是当前符合条件的边的最大权值(符合条件的边指两段点都在一个部分),问你如何分,可以让耗费最小 分析:把当前l到r的边进行排序,从大到小,从大的开始不断加边,判断当前能否形成二分图,如果能形成二分图,继续加边 如果不能形成二分图,那当前边的权值就是最小耗费(是不是很眼熟) 思路很清晰,现在我们要解决的是如何判断可以形成二分图,有两种,一个是2染色当前图(肯定超时) 所以只剩一种方法,带权并查集…
Problem description Linear Kingdom has exactly one tram line. It has n stops, numbered from 1 to n in the order of tram's movement. At the i-th stop ai passengers exit the tram, while bipassengers enter it. The tram is empty before it arrives at the…