codeforces 121 E. Lucky Array】的更多相关文章

time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky dig…
E. Lucky Array time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains onl…
E. Lucky Array Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467are not. Petya has an arra…
题目连接:Codeforces 442C Artem and Array 题目大意:给出一个数组,每次删除一个数.删除一个数的得分为两边数的最小值,假设左右有一边不存在则算作0分. 问最大得分是多少. 解题思路:首先将连续的a,b,c,a > b && c > b的情况将c掉,获得min(a,b)分,这样处理后数组变成一个递増再递减的序列,除了最大和第二大的取不到.其它数字均能够得分. 例子:4 10 2 2 8 #include <cstdio> #include…
Codeforces Round #504 D. Array Restoration 题目描述:有一个长度为\(n\)的序列\(a\),有\(q\)次操作,第\(i\)次选择一个区间,将区间里的数全部改为\(i\),序列\(a\)的每个位置至少被改一次.得到最终的序列,然后将序列里的某些位置变成\(0\),输出一种可能的置零之前的最终序列,或无解. solution 求出每种数字最长的染色区间,按这个区间染色,记下没出现的数字.染色后如果存在\(0\)联通块,则用没出现的数字从大到小染色(一个联…
Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. Petya has an array consisting o…
http://codeforces.com/contest/121/problem/E 话说这题貌似暴力可A啊... 正解是想出来了,结果重构代码,调了不知道多久才A 错误记录: 1.线段树搞混num(节点编号)和l(区间端点) 2.之前的dfs没有分离,写的非常混乱,迫不得已重构代码 #include<cstdio> #include<algorithm> #include<cstring> #include<vector> using namespace…
题目链接 题目大意: 定义只含数字$4,7$的数字为幸运数, 给定序列, 区间加正数, 区间询问多少个幸运数 题解: 对于每一个数, 求出它和第一个比它大的幸运数之差, 则问题转化为区间加,查询$0$的个数 可以维护最大值即最大值的个数, 对于最大值$<=0$直接打标记修改即可 对于最大值$>0$的暴力转移到下一个幸运数, 因为对于每个幸运数来说, 最多有n个元素暴力修改, 可以看成n个点单点更新 所以暴力修改的复杂度$O(Cnlogn)$, $C$为总幸运数个数 总复杂度$O((n+m)lo…
D. Array Division time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Vasya has an array a consisting of positive integer numbers. Vasya wants to divide this array into two non-empty consecuti…
A. Lesha and array splitting time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output One spring day on his way to university Lesha found an array A. Lesha likes to split arrays into several parts.…