CF 573B
Bear and Blocks
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Limak is a little bear who loves to play. Today he is playing by destroying block towers. He built n towers in a row. The i-th tower is made of hi identical blocks. For clarification see picture for the first sample.
Limak will repeat the following operation till everything is destroyed.
Block is called internal if it has all four neighbors, i.e. it has each side (top, left, down and right) adjacent to other block or to the floor. Otherwise, block is boundary. In one operation Limak destroys all boundary blocks. His paws are very fast and he destroys all those blocks at the same time.
Limak is ready to start. You task is to count how many operations will it take him to destroy all towers.
Input
The first line contains single integer n (1 ≤ n ≤ 105).
The second line contains n space-separated integers h1, h2, ..., hn (1 ≤ hi ≤ 109) — sizes of towers.
Output
Print the number of operations needed to destroy all towers.
题意: 就是给你N个高度,每次删除和外界相接触的方块,问多少次可以删完
竟然是Dp
对于每一个高度, 其决定值得是两边的高度,然而直接暴力T了,应该Dp
Dp【i】表示 第i个高度在第几秒会被完全删完
从左往右考虑一次, 从右往左考虑一次
然后对于每个 Dp值取min, 所有值取MAX;
(感谢学长ChildOfHulu♂指导)
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + ;
int Num[maxn];
int Dp[maxn];
int Dp2[maxn];
set<int> S;
int main()
{
ios::sync_with_stdio(false);
cin.tie();
int n;
cin >> n;
for(int i = ; i <= n; ++i)
{
//int t;
cin >> Num[i];
}
for(int i = ; i <= n; ++i)
Dp[i] = min(Dp[i-]+,Num[i]);
for(int i = n; i >= ; i--)
Dp2[i] = min(Dp2[i+]+,Num[i]);
int ans = ;
for(int i = ; i <= n; ++i)
ans = max(ans, min(Dp[i],Dp2[i]));
cout << ans << endl;
}
CF 573B的更多相关文章
- ORA-00494: enqueue [CF] held for too long (more than 900 seconds) by 'inst 1, osid 5166'
凌晨收到同事电话,反馈应用程序访问Oracle数据库时报错,当时现场现象确认: 1. 应用程序访问不了数据库,使用SQL Developer测试发现访问不了数据库.报ORA-12570 TNS:pac ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- cf Round 613
A.Peter and Snow Blower(计算几何) 给定一个点和一个多边形,求出这个多边形绕这个点旋转一圈后形成的面积.保证这个点不在多边形内. 画个图能明白 这个图形是一个圆环,那么就是这个 ...
- ARC下OC对象和CF对象之间的桥接(bridge)
在开发iOS应用程序时我们有时会用到Core Foundation对象简称CF,例如Core Graphics.Core Text,并且我们可能需要将CF对象和OC对象进行互相转化,我们知道,ARC环 ...
- [Recommendation System] 推荐系统之协同过滤(CF)算法详解和实现
1 集体智慧和协同过滤 1.1 什么是集体智慧(社会计算)? 集体智慧 (Collective Intelligence) 并不是 Web2.0 时代特有的,只是在 Web2.0 时代,大家在 Web ...
- CF memsql Start[c]UP 2.0 A
CF memsql Start[c]UP 2.0 A A. Golden System time limit per test 1 second memory limit per test 256 m ...
- CF memsql Start[c]UP 2.0 B
CF memsql Start[c]UP 2.0 B B. Distributed Join time limit per test 1 second memory limit per test 25 ...
- CF #376 (Div. 2) C. dfs
1.CF #376 (Div. 2) C. Socks dfs 2.题意:给袜子上色,使n天左右脚袜子都同样颜色. 3.总结:一开始用链表存图,一直TLE test 6 (1)如果需 ...
- CF #375 (Div. 2) D. bfs
1.CF #375 (Div. 2) D. Lakes in Berland 2.总结:麻烦的bfs,但其实很水.. 3.题意:n*m的陆地与水泽,水泽在边界表示连通海洋.最后要剩k个湖,总要填掉多 ...
随机推荐
- Iterator迭代器
java.util.Iterator 迭代器iterator,是一个接口,不能够直接使用,需要使用Iterator接口的实现类对象,而获取实现类的的对象的方式为: Collection接口中有一个方法 ...
- 解析/proc/net/dev
https://stackoverflow.com/questions/1052589/how-can-i-parse-the-output-of-proc-net-dev-into-keyvalue ...
- Spark 整合ElasticSearch
Spark 整合ElasticSearch 因为做资料搜索用到了ElasticSearch,最近又了解一下 Spark ML,先来演示一个Spark 读取/写入 ElasticSearch 简单示例. ...
- 魔改版BBR
魔改版bbr加速: wget -N --no-check-certificate "https://raw.githubusercontent.com/chiakge/Linux-NetSp ...
- spring注解第04课 @Import
1.beans package com.atguigu.bean; public class Blue { public Blue(){ System.out.println("blue.. ...
- 访问权限,public private protected
百度经验这篇文章很不错:https://jingyan.baidu.com/article/bad08e1e8e9a9b09c851219f.html
- BN_batch normalization
参考: https://zhuanlan.zhihu.com/p/27938792 做法 设,每个batch输入是 (其中每个 都是一个样本, 是batch size) 假如在第一层后加入Batch ...
- springboot的@CrossOrigin注解解决细粒度的配置跨域
import java.util.HashMap; import org.springframework.web.bind.annotation.CrossOrigin; import org.spr ...
- eslint 关于CRLF或者LF报错
在拉取项目代码时,如果有eslint代码校验,但是本地打开会有于CRLF或者LF报错报错,那么怎么处理呢? git有个自动转换换行符功能,在文件commit时会自动转换换行符格式: 不想使用,也可以通 ...
- JSP动态页面技术
1.JSP和html的区别 处理过程的区别 HTML 浏览器发送一个请求到服务器,服务器找到这个页面直接返回. JSP 浏览器发送一个请求道服务器,服务器判断到时.jsp结尾,去调用JSP引擎,JSP ...