cf C. Levko and Array Recovery】的更多相关文章

http://codeforces.com/contest/361/problem/C 这道题倒着一次,然后正着一次,在正着的一次的时候判断合不合法就可以. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; ; ],ans[]; ],l[],r[],d[]; int n,m; int flag; int main() { while(scanf("%d%…
[codeforces 360]A. Levko and Array Recovery 试题描述 Levko loves array a1, a2, ... , an, consisting of integers, very much. That is why Levko is playing with array a, performing all sorts of operations with it. Each operation Levko performs is of one of…
题目链接 线段树的逆过程,想了老一会,然后发现应该是包含区间对存在有影响,就不知怎么做了...然后尚大神,说,So easy,你要倒着来,然后再正着来,判断是不是合法就行了.然后我乱写了写,就过了.数据难道又水了... #include <stdio.h> #include <string.h> #include <iostream> #include <queue> #include <algorithm> using namespace st…
http://codeforces.com/contest/361/problem/D 用二分搜索相邻两个数的差的绝对值,然后用dp记录数改变的次数.dp[i]表示在i之前改变的次数,如果|a[i]-a[j]|<=(i-j)*mid 需要改变. #include <cstdio> #include <cstring> #include <algorithm> #define LL __int64 using namespace std; ; ]; int n,k;…
题目链接:http://codeforces.com/contest/361/problem/C 题意:对一个数列有这么两个操作 1.(1,l,r,p)..将区间[l,r]所有数都加上p 2.(2,l,r,m).求出区间[l,r]的最大值为m 现在告诉这么一些操作(<5000个),问能否找到一个原始的数列,有则输出YES与这个数列,否则输出NO,答案可能不唯一输出任何合法的都行. 题解:先给数组赋予最大的初值然后倒着处理,遇到1就减去.如果是2,将这一区间里所有数都去min(自身,MAX) 处理…
链接:CF360B 题目: B. Levko and Array time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Levko has an array that consists of integers: a1, a2, ... , an. But he doesn’t like this array at all. Levk…
Levko and Array time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Levko has an array that consists of integers: a1, a2, ... , an. But he doesn’t like this array at all. Levko thinks that the…
刚才面试了一个蛮有意思的DP题目,脑子断片,没写出来,不过早上状态还是蛮好的 一个长度为n的序列最多改变k次,使相邻两数之差绝对值的最大值最小 三维的dp我先尝试写一下 Codeforces 360B Levko and Array 其实是n^2logm的,太nb了 去二分答案这个很好想,因为既然这个数满足,大于它肯定满足,然后就是去判断这个数字存不存在了.很容易想到贪心,但是贪心会有个问题,就是你无法确定你要修改的哪个数,很容易你就可以找到自己的bug.最后这个是个dp,dp[i]表示从n到i…
Discription Levko has an array that consists of integers: a1, a2, ... , an. But he doesn’t like this array at all. Levko thinks that the beauty of the array a directly depends on value c(a), which can be calculated by the formula: The less value c(a)…
You are given an array of integers. Vasya can permute (change order) its integers. He wants to do it so that as many as possible integers will become on a place where a smaller integer used to stand. Help Vasya find the maximal number of such integer…