SOJ.Opening Ceremony

1003. Opening Ceremony

 
 
总提交数量: 123 通过数量: 34
 
     
     
 

时间限制:1秒    内存限制:256兆

题目描述

For the grand opening of the algorithmic games in NlogNsglow, a row of tower blocks is set to be demolished in a grand demonstration of renewal. Originally the plan was to accomplish this with controlled explosions, one for each tower block, but time constraints
now require a hastier solution.

To help you remove the blocks more rapidly you have been given the use of a Universal Kinetic / Incandescent Energy Particle Cannon (UKIEPC). On a single charge, this cutting-edge contraption can remove either all of the floors in a single tower block, or
all the x-th floors in all the blocks simultaneously, for user’s choice of the floor number x. In the latter case, the blocks that are less than x floors high are left untouched, while for blocks having more than x floors, all the floors above the removed
x-th one fall down by one level.

Given the number of floors of all towers, output the minimum number of charges needed to eliminate all floors of all blocks.

输入格式

The first line of input contains the number of blocks n, where 2 &#20;<= n <=&#20; 100 000. The second line contains n consecutive block heights hi for i = 1, 2, ..., n, where 1 <=&#20; hi <=&#20; 1 000 000.

输出格式

Output one line containing one integer: the minimum number of charges needed to tear down all the blocks.

样例输入

将样例输入复制到剪贴板

样例一:
6
2 1 8 8 2 3
样例二:
5
1 1 1 1 10

样例输出

样例一:
5
样例二:
2

Problem Source: 2015年每周一赛第四场

时间: 2024-10-16 21:36:25

SOJ.Opening Ceremony的相关文章

CodeForcesGym 100502E Opening Ceremony

Opening Ceremony Time Limit: 5000ms Memory Limit: 524288KB This problem will be judged on CodeForcesGym. Original ID: 100502E64-bit integer IO format: %I64d      Java class name: (Any) For the grand opening of the algorithmic games in NlogNsglow, a r

Opening Ceremony

Problem E: Opening Ceremony Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 137  Solved: 30 [Submit][Status][Web Board] Description Input Output Sample Input 6 2 1 8 8 2 3 Sample Output 5 HINT 题意:有一堆砖块,每一次操作可以选择消去任意一行,也可以选择消去任意一列.求要消去所有的砖块需要最小的操作数. 思

csu 1578 Opening Ceremony (递推 )

题意:有一个排n个建筑 每个高不定 现在要消去全部建筑 方法有两种 1 消去高度为某值的全部方块 2 消去一整个建筑 问 如何通过最少步骤消去 思路:首先将数组从大到小排序 if(i+a[i]<ans) ans=i+a[i]; #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int a[1000000+100]; int cmp(int a,int b) { r

csu 1578: Opening Ceremony(DP)

#include<cstdio> #include<cstring> #include<algorithm> using namespace std; int a[100005]; int dp[100005]; int main() { int n; while(scanf("%d",&n)==1) { for(int i=1;i<=n;i++) scanf("%d",&a[i]); sort(a+1,a+

SOJ - 11512

11512. Big Circle Constraints Time Limit: 2 secs, Memory Limit: 256 MB Description On the opening ceremony of World Cup there was a part where many kids from around the world was trying to make a big circle on the field which symbolized tolerance and

可穿戴设备的发展与挑战

可穿戴设备的发展和挑战 “可穿戴设备”已经不是新鲜词汇了,即直接穿在身上或整合到衣服或配件里的一种便携式设备.几十年的发展中,它已不仅仅是一种硬件设备,更是通过软件支持,数据交互,云端交互等高科技来实现强大的功能.它并非只是移动互联网时代产生的衍生品,在很久以前这种思想便已萌生在上世纪70年代的赌场里.经过平稳的发展后,现代社会里可穿戴设备已经对我们的生活和感知带来了比较大的转变. 关于它的发展史已经没有回顾的必要,总体是随着最新的科技前沿和智能手机的更迭在稳步发展.通过研讨,我们总结出了在现阶

【英语魔法俱乐部——读书笔记】 3 高级句型-简化从句&amp;倒装句(Reduced Clauses、Inverted Sentences) 【完结】

[英语魔法俱乐部——读书笔记] 3 高级句型-简化从句&倒装句(Reduced Clauses.Inverted Sentences):(3.1)从属从句简化的通则.(3.2)形容词从句简化.(3.3)名词从句简化.(3.4)副词从句简化.(3.5)简化从句练习.(3.6)倒装句 3.1 从属从句简化的通则(Generally Reduction Rules of Dependent Clause) 3.1.1 简化从句:英语语法以句子为研究对象,而其句型也分为简单句.复句和合句之分,其中简单句

可穿戴设备还能怎么玩?

根据市场研究公司Juniper近日发表的报告预测,2018年全球可穿戴设备出货量将达到1.3亿台,10倍于2013年,许多 业内人士无疑将可穿戴设备视为继智能手机之后的下一个互联网浪潮制高点.就在刚刚结束的CES年度大展上,从硬件创业公司Razer到索尼等大型消费电子 制造商,再到英特尔.爱普生等芯片商和耗材商,几乎所有与硬件沾边的公司都在谋划这个潜在市场.这种情况下,你不得不承认,"可穿戴设备"的热潮已经被点 燃了.   听上去很酷,这或许是当前可穿戴设备普及的最大障碍之一.普通消费

The Plaza Beauty also are ghd cheap australia

The Plaza Beauty also are ghd cheap australia raffling off free refurbishments every hour. Some moat people that have long hair be needing being extra careful since the extra pressure while curling the sides, Can certainly break fairly and cause spli