Codeforces Round #371 & HihoCoder1529【玄学】
描述
给定一个长度为 n 的非负整数序列 a[1..n]。
你每次可以花费 1 的代价给某个 a[i] 加1或者减1。
求最少需要多少代价能将这个序列变成一个不上升序列。
输入
第一行一个正整数 n。
接下来 n 行每行一个非负整数,第 i 行表示 a[i]。
1 ≤ n ≤ 500000
0 < a[i] ≤ 109
输出
一个非负整数,表示答案。
样例解释
[5,3,4,5] -> [5,4,4,4]
- 样例输入
-
4
5
3
4
5 - 样例输出
-
2
玄学,堆???
想了两节课,无果。。。。。。。。。。。。
http://codeforces.com/blog/entry/47094?#comment-315161
Codeforces Round #371 & HihoCoder1529【玄学】的更多相关文章
- Codeforces Round #371 (Div. 1)
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...
- Codeforces Round #371 (Div. 2)B. Filya and Homework
题目链接:http://codeforces.com/problemset/problem/714/B 题目大意: 第一行输入一个n,第二行输入n个数,求是否能找出一个数x,使得n个数中的部分数加上x ...
- Codeforces Round #371 (Div. 2) - B
题目链接:http://codeforces.com/contest/714/problem/B 题意:给定一个长度为N的初始序列,然后问是否能找到一个值x,然后使得序列的每个元素+x/-x/不变,最 ...
- Codeforces Round #371 (Div. 2) - A
题目链接:http://codeforces.com/contest/714/problem/A 题意:有两个人A,B 给定A的时间区间[L1,R1], B的时间区间[L2,R2],然后在正好K分钟的 ...
- 严格递增类的dp Codeforces Round #371 (Div. 1) C dp
http://codeforces.com/contest/713 题目大意:给你一个长度为n的数组,每次有+1和-1操作,在该操作下把该数组变成严格递增所需要的最小修改值是多少 思路:遇到这类题型, ...
- Codeforces Round #371 (Div. 2) C 大模拟
http://codeforces.com/contest/714/problem/C 题目大意:有t个询问,每个询问有三种操作 ①加入一个数值为a[i]的数字 ②消除一个数值为a[i]的数字 ③给一 ...
- Codeforces Round #371 (Div. 1) C. Sonya and Problem Wihtout a Legend 贪心
C. Sonya and Problem Wihtout a Legend 题目连接: http://codeforces.com/contest/713/problem/C Description ...
- Codeforces Round #371 (Div. 1) D. Animals and Puzzle 二维倍增
D. Animals and Puzzle 题目连接: http://codeforces.com/contest/713/problem/D Description Owl Sonya gave a ...
- Codeforces Round #371 (Div. 2) C. Sonya and Queries 水题
C. Sonya and Queries 题目连接: http://codeforces.com/contest/714/problem/C Description Today Sonya learn ...
随机推荐
- bootstrap-datetimepicker日期控件下载
bootstrap-datetimepicker.js bootstrap-datetimepicker.zh-CN.js bootstrap-datetimepicker.min.css 下载网站: ...
- POJ 2186 Popular Cows(强连通分量Kosaraju)
http://poj.org/problem?id=2186 题意: 一个有向图,求出点的个数(任意点可达). 思路: Kosaraju算法的第一次dfs是后序遍历,而第二次遍历时遍历它的反向图,从标 ...
- Partition List,拆分链表
问题描述: Given a linked list and a value x, partition it such that all nodes less than x come before no ...
- thinkphp getField("xxxxx", true); 得到一个字段所有值组成的的数组
很多时候我们只需要一张表里某个字段的值,组成的数组 $Channel = D('channel');$channelList = $Channel->order('user_name')-> ...
- 关于 MongoDB 复制集
为什么要使用复制集 1.备份数据通过自带的 mongo_dump/mongo_restore 工具也可以实现备份,但是毕竟没有复制集的自动同步备份方便. 2.故障自动转移部署了复制集,当主节点挂了后, ...
- CSS3:@font-face规则
前言 过去,Web设计师为了保证网站能够正常显示,只能使用“Web安全字体”,即每台机器都预装的字体.但Web安全字体有时并不好看... @font-face能够使得任何一台机器能够显示理想中的字体. ...
- Linux常用插件
文件传输 虚拟机用xshell连接时,拖拽传输插件 yum install lrzsz setup界面化工具 yum install setuptool yum install ntsysv # ...
- Codeforces Round #412
第一题水题,8分钟1a #include<map> #include<set> #include<cmath> #include<queue> #inc ...
- LabVIEW之安装队列工具包AMC安装问题解决
LabVIEW之安装队列工具包AMC安装问题解决--VIPM无法连接LabVIEW 彭会锋 参考资料: http://www.labviewpro.net/forum_post_detail.php? ...
- idea Controller层编译Mapper层报错
解决方案:ctrl+alt+s 搜索insp 设置spring的编译Error改为Warning就可以了