Codeforces Round #318 (Div. 2) D - Bear and Blocks
来源:互联网 发布:缩略图软件下载 编辑:程序博客网 时间:2024/05/29 18:53
题意:有n列方块,每列方块的高度为
先考虑普遍情况
3
1 2 1
这种情况只需要2个步骤
5
1 2 3 2 1
这种情况只需要3个步骤
7
1 2 3 4 3 2 1
这种情况只需要4个步骤
所以。。只需要找这n列中的这些部分中最大的那个部分高度,就是需要的操作次数
//author: CHC//First Edit Time: 2015-09-09 12:55#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <set>#include <vector>#include <map>#include <queue>#include <set>#include <algorithm>#include <limits>using namespace std;typedef long long LL;const int MAXN=1e+5 + 100;const int INF = numeric_limits<int>::max();const LL LL_INF= numeric_limits<LL>::max();int A[MAXN],n;int dl[MAXN],dr[MAXN];int main(){ while(~scanf("%d",&n)){ for(int i=1;i<=n;i++)scanf("%d",&A[i]); dl[0]=0; for(int i=1;i<=n;i++)dl[i]=min(dl[i-1]+1,A[i]); dr[n+1]=0; for(int i=n;i>=1;i--)dr[i]=min(dr[i+1]+1,A[i]); int ans=0; for(int i=1;i<=n;i++)ans=max(ans,min(dl[i],dr[i])); printf("%d\n",ans); } return 0;}
0 0
- Codeforces Round #318 (Div. 2) D - Bear and Blocks
- Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 2)D Bear and Blocks
- Codeforces Round #318-(D. Bear and Blocks)
- Codeforces Round #318 D. Bear and Blocks
- Codeforces Round #318 D. Bear and Blocks
- Codeforces Round #318 574D Bear and Blocks(dp)
- Codeforces Round #318 D. Bear and Blocks DP
- Codeforces Round #226 (Div. 2) D. Bear and Floodlight
- CodeForce #318 div 2 D Bear and Blocks
- Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 1) B. Bear and Blocks dp
- Codeforces Round #318 (Div. 2) A. Bear and Elections
- Codeforces Round #318 (Div. 2) Bear and Poker
- Codeforces Round #318 (Div. 2) C - Bear and Poker
- Codeforces Round #318 (Div. 2) E - Bear and Drawing
- 573B. Bear and Blocks(Codeforces Round #318)
- Codeforces Round #318 573B. Bear and Blocks
- Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) D. Bear and Two Paths
- Codeforces Round #351 (VK Cup 2016 Round 3, Div. 2 Edition) D. Bear and Two Paths
- Docker镜像和容器操作(一)
- hdu 5349 MZL's simple problem
- HDU 2846 Repository(字典树)
- C++数据结构之Linked Stack(链式栈)
- TimeoutFutureTask实现
- Codeforces Round #318 (Div. 2) D - Bear and Blocks
- wxWidgets和QT之间的选择
- 链表翻转的递归和非递归实现
- ZOJ 2112 Dynamic Rankings 树状数组套主席树 单点修改求动态区间第K大
- 读书笔记之深入理解操作系统(10)
- 三种单例模式的C++实现
- CodeForces 337A - Puzzles
- redis的学习地址
- eclipse 自动生成注释