Codeforces 981 E - Addition on Segments】的更多相关文章

E - Addition on Segments 思路: dp dp[i]表示构成i的区间的右端点 先将询问按r排序 然后,对于每次询问,每次枚举 i 从 n-x 到 1,如果dp[i] >= l , 那么 dp[i+x] = max(dp[i+x], dp[j]) #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pi acos(-1.0) #define LL…
Codeforces 981 D.Bookshelves 题目大意: 给n个数,将这n个数分为k段,(n,k<=50)分别对每一段求和,再将每个求和的结果做与运算(&).求最终结果的最大值. 思路: 将答案ans二进制表示,按位枚举,从最高位i开始,检查ans|(1<<i)是否能够得到,如果能,则ans|=1<<i,向低位继续枚举:不能,就直接继续向低位枚举. 检查 ans|(1<<i)能否得到:每次用DP的方式寻找,dp[i][j]表示将前i个数分为j段…
A /*Huyyt*/ #include<bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) #define pb push_back using namespace std; typedef long long ll; typedef unsigned long long ull; ][] = {{, }, {, }, {, -}, { -, }, {, }, {, -}, { -, -}, { -, }}; ; + + + + 1e9…
Codeforces Round #535 E2-Array and Segments (Hard version) 题意: 给你一个数列和一些区间,让你选择一些区间(选择的区间中的数都减一), 求最后最大值与最小值的差值最大,并输出选择的区间 思路: 在n=300的时候,我们是枚举每个数作为最小值,应用所有覆盖它的区间,并且没 次都更行差值的最大值. 但是这里的n=1e5,所以我们不能用O(n*n*m),但是我们看到这里的m=300 所以可以从m入手,枚举区间,就是记录每个区间的两个端点,利用…
考虑每个点i在什么情况下会成为最大值. 当选的区间子集是 包含i的区间的一个子集的时候,i肯定会是最大值. 所以我们就可以用这种方法得到所有点的可能的最大值是多少... 也就是说,最后的局面可以仅由一个从左到右扫一遍时单峰的区间子集构成,这样不会丧失任意一个可行解.... 于是就可以直接线段树打标记+bitset优化可行背包问题....暴力跑一遍就能A啦.... Discription Grisha come to a contest and faced the following proble…
D. Nested Segments 题目连接: http://www.codeforces.com/contest/652/problem/D Description You are given n segments on a line. There are no ends of some segments that coincide. For each segment find the number of segments it contains. Input The first line…
任意门:http://codeforces.com/contest/652/problem/D D. Nested Segments time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given n segments on a line. There are no ends of some segments th…
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output Vika has an infinite sheet of squared paper. Initially all squares are white. She introduced a two-dimensional coordinate system on this sheet a…
题目链接:http://codeforces.com/problemset/problem/305/A 题目意思:给出一个序列,需要从中选择一些数,这些数需要满足:任意的两个数中每一位至少有一个数满足该位有0.例如,406, 10(可以看成010)是符合条件的: 406, 11 就不符合条件,因为个位上这两个数都不包含0. 一开始想得太过复杂:把整型的数保存到字符数组中,再用strstr函数找出是否有0的存在,但是这样做根本不能解决问题,因为不能得出0的具体位置.并且不能判断出两个数中的不同位至…
D. Vika and Segments time limit per test:  2 seconds     memory limit per test:  256 megabytes input : standard input output:  standard output Vika has an infinite sheet of squared paper. Initially all squares are white. She introduced a two-dimensio…