【模拟】NCPC 2014 E ceremony
题目链接:
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1791
题目大意:
N栋大楼(N<=100000),拆除的时候有两种选择的操作,可以拆掉一整栋,或者把当前所有大楼的第x层拆掉(高度小于x的没用),并且x以上的所有楼层高度-1.(相当于所有高于x的大楼抽掉一层)
问把N栋大楼拆掉至少要几次拆除操作。
题目思路:
【模拟】
先将大楼高度排序,之后考虑分界线,枚举I,I之后的大楼都是被单个拆除,而I和I之前的大楼都是被一层一层拆除。ans=min(n-i+h[i])
- //
- //by coolxxx
- //#include<bits/stdc++.h>
- #include<iostream>
- #include<algorithm>
- #include<string>
- #include<iomanip>
- #include<map>
- #include<stack>
- #include<queue>
- #include<set>
- #include<bitset>
- #include<memory.h>
- #include<time.h>
- #include<stdio.h>
- #include<stdlib.h>
- #include<string.h>
- //#include<stdbool.h>
- #include<math.h>
- #define min(a,b) ((a)<(b)?(a):(b))
- #define max(a,b) ((a)>(b)?(a):(b))
- #define abs(a) ((a)>0?(a):(-(a)))
- #define lowbit(a) (a&(-a))
- #define sqr(a) ((a)*(a))
- #define swap(a,b) ((a)^=(b),(b)^=(a),(a)^=(b))
- #define mem(a,b) memset(a,b,sizeof(a))
- #define eps (1e-8)
- #define J 10
- #define mod 1000000007
- #define MAX 0x7f7f7f7f
- #define PI 3.14159265358979323
- #define N 100004
- using namespace std;
- typedef long long LL;
- int cas,cass;
- int n,m,lll,ans;
- int h[N];
- bool cmp(int a,int b)
- {
- return a<b;
- }
- int main()
- {
- #ifndef ONLINE_JUDGE
- // freopen("1.txt","r",stdin);
- // freopen("2.txt","w",stdout);
- #endif
- int i,j,k;
- // for(scanf("%d",&cass);cass;cass--)
- // for(scanf("%d",&cas),cass=1;cass<=cas;cass++)
- // while(~scanf("%s",s+1))
- while(~scanf("%d",&n))
- {
- for(i=;i<=n;i++)
- scanf("%d",&h[i]);
- sort(h+,h++n,cmp);
- ans=min(n,h[n]);
- for(i=;i<n;i++)
- ans=min(ans,n-i+h[i]);
- printf("%d\n",ans);
- }
- return ;
- }
- /*
- //
- //
- */
【模拟】NCPC 2014 E ceremony的更多相关文章
- 【模拟】NCPC 2014 D Dice Game
题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1790 题目大意: 两个人,每个人有两个骰子,每个骰子可以等概率取[a,b],问哪个人两 ...
- 【模拟】NCPC 2014 K Train passengers
题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1797 题目大意: 有N个车站,火车一共可以坐M个人,每个车站下车Ai,上车Bi个人,在 ...
- 模拟 Coder-Strike 2014 - Round 1 A. Poster
题目地址:http://codeforces.com/problemset/problem/412/A /* 模拟:题目没看懂,但操作很简单,从最近的一头(如果不在一端要先移动到一端)往另一头移动,顺 ...
- 【高精度】NCPC 2014 C catalansqure
题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1789 题目大意: 求大卡特兰数..公式如下.输入n求Sn(n<=5000) 题目 ...
- 【动态规划】【缩点】NCPC 2014 G Outing
题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1793 题目大意: 一辆公交车,上面M个座位,N个人(M<=N<=1000) ...
- 【KMP】【最小表示法】NCPC 2014 H clock pictures
题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1794 题目大意: 两个无刻度的钟面,每个上面有N根针(N<=200000),每个 ...
- 【图论】【宽搜】【染色】NCPC 2014 A Ades
题目链接: http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1787 题目大意: N个点M条无向边(N,M<=200000),一个节点只能有一个 ...
- hdu 4915 Parenthese sequence(模拟)2014多培训学校5现场
Parenthese sequence Time Limit: ...
- CodeForcesGym 100502E Opening Ceremony
Opening Ceremony Time Limit: 5000ms Memory Limit: 524288KB This problem will be judged on CodeForces ...
随机推荐
- 使用PHP实现蜘蛛访问日志统计
$useragent = addslashes(strtolower($_SERVER['HTTP_USER_AGENT'])); if (strpos($useragent, 'googlebot' ...
- java 钱币的单位转换
将钱转成转换为带指定单位的钱 int money = 10; NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.US); System ...
- java的各个队列之间的联系和区别是什么
java的各个并发队列之间的联系和区别 java.util.concurrent是在并发编程中很常用的实用工具类 ArrayBlockingQueue, DelayQueue, LinkedBlock ...
- 【HOJ1356】【Miller_rabin素性测试】Prime Judge
Given a positive integer, your job is writing a program to determine whether it is a prime number or ...
- iOS 视频播放横屏,隐藏状态栏
MPMoviePlayerViewController *moviePlayerViewController = [[MPMoviePlayerViewController alloc] init]; ...
- c++ undefined reference to mysqlinit
Solved g++ $(mysql_config --cflags) file.cpp -o filename $(mysql_config --libs)
- 移动Web开发,4行代码检测浏览器是否支持position:fixed
不废话,直接上代码 var div = document.createElement('div'); div.style.cssText = 'display:none;position:fixed; ...
- nav
$(document).ready(function() { $(window).resize(function(){ var need=0; var ul_max_width = $(window) ...
- Ubuntu14.02 Sublimte2安装
$sudo add-apt-repository ppa:webupd8team/sublime-text-2 $sudo apt-get update $sudo apt-get install s ...
- dictionary(字典)
dictionary(字典): 字典对象 字典是一种key - value 的数据类型,使用就像我们上学用的字典,通过笔划.字母来查对应页的详细内容. 1. dic={"n ...