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 ...
随机推荐
- Vjudge - E - 这是高中数学向量题
2017-07-15 22:29:06 writer:pprp 评价,用到了叉乘,很麻烦,C++构造知识必须扎实 题目如下: 我们用逆时针方向的顶点序列来表示,我们很想了解这块地的基本情况,现在请你编 ...
- tcp westwood源代码分析
/* * TCP Westwood+: end-to-end bandwidth estimation for TCP * * Angelo Dell'Aera: author of the firs ...
- spring boot2.1读取 apollo 配置中心2
第二篇:创建spring boot2.1项目 引用apollo的java客户端jar包 <dependency> <groupId>com.ctrip.framework.ap ...
- Android -- 提交数据到服务器,Get Post方式, 异步Http框架提交
1. 发送请求到服务器有几种方式 (1)HttpURLConnection (2)Httpclient 同步框架 (3)AsyncHttpClient 异步框架 (https://github.com ...
- 在 Spark 中使用 IPython Notebook
本文是从 IPython Notebook 转化而来,效果没有本来那么好. 主要为体验 IPython Notebook.至于题目,改成<在 IPython Notebook 中使用 Spark ...
- javascript深入浅出
第一章 数据类型 1,六种数据类型:原始类型(number,string,boolean,null,undefined) + object对象(Function Array Date) 2,隐式转换: ...
- 英语词根与单词的说文解字---词根示例1、第10页 st(at)
英语词根与单词的说文解字---词根示例1.第10页 st(at) 一.总结 一句话总结: 站 state,establish,constitution 英 [ɪ'stæblɪʃ; e-] 美 [ɪˈ ...
- mongo docker image
mongo 保存压缩镜像 docker save -o ~/Desktop/mongo.tar mongo 7za a -mx=9 ~/Desktop/mongo.tar{.7z,} 导入或拉取镜像 ...
- confluence+Mysql5.7 版本安装破解
此篇稍微过下msyql 的处理方案:其他详细请参照上一篇文章地址:https://www.cnblogs.com/flyrock/p/9693327.html mysql 最新版本8.0 有点坑,co ...
- RedHat/CentOS 7通过nmcli命令管理网络教程
Red Hat Enterprise Linux 7 和CentOS 7 的网络管理实际上是对NetworkManager的管理,可通过nmcli命令进行控制,下面小编就给大家介绍下RedHat/Ce ...