Sicily 13910. Opening Ceremony
来源:互联网 发布:javascript调用数据库 编辑:程序博客网 时间:2024/06/10 01:25
贪心算法:比较底部可以消去一行的个数和最高塔那个多,消去多的那个,数据有点多,用c输入比较好
#include <iostream>#include <algorithm>#include <cstdio> using namespace std;int arr[1000000];int main(){int n;scanf("%d",&n);for(int i=0; i < n; ++i)scanf("%d",&arr[i]);sort(arr,arr+n);int max_high=n-1,count=0;int nozero=-1;while(true){if(arr[max_high] >= max_high-nozero+1){arr[max_high]=0;max_high--;count++;}else{bool check=false;for(int i=0; i <= max_high; ++i){arr[i]--;if(arr[i]>0&&check==false){check=true;nozero=i;}}count++;}int k;for(k=0; k < n; ++k){if(arr[k] > 0) break;}if(k == n) break;}printf("%d\n",count);}
0 0
- Sicily 13910. Opening Ceremony
- Sicily 周赛 Opening Ceremony
- Opening ceremony
- Opening Ceremony
- ASPM Opening Ceremony
- SOJ.Opening Ceremony
- CSU1578: Opening Ceremony
- Opening Ceremony----思维题
- csu 1578: Opening Ceremony(DP)
- NCPC 2014 Problem E Opening Ceremony Problem ID: ceremony
- The Opening Ceremony of my blog
- CF 2014 Nordic Collegiate Programming Contest E Opening Ceremony
- Opening
- opening
- Opening
- 告别仪式 departure ceremony
- wedding ceremony may
- CSU 1791 ceremony
- java 阻塞队列
- 你真的懂iOS的autorelease吗?
- 使用TDI与WinSock进行客户端服务器编程
- java基础概念之多态
- (9)设计模式:State
- Sicily 13910. Opening Ceremony
- POJ_2503_Babelfish(map or 字典树)
- JVM中一些容易混淆的概念
- Leetcode: Find Peak Element
- greenplum4.3的安装与配置
- Mysql主从配置,实现读写分离
- cookie,request,session与application页面之间参数的传递
- windows中用Virtual Box虚拟机安装ubuntu的一些问题
- iOS:一种直接修改frame的某个属性的方法