HDU 1257 最少拦截系统
来源:互联网 发布:常见网络端口号 编辑:程序博客网 时间:2024/04/30 09:10
贪心, 从前面往后读取,对于每一个高度,都要用之前一个系统最接近的高度来消灭,这样才最省。
#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <string>#include <algorithm>#include <fstream>#include <set>#include <map>#include <queue>#include <stack>#include <list>#include <vector>#include <cmath>#include <iomanip>#include <cmath>typedef long long LL;typedef unsigned long long LLU;const double PI=acos(-1.0);using namespace std;#define MAXN 100000+10#define INF 1 << 30int main (){ int n; while(scanf("%d",&n) != EOF){ int a[MAXN] = {0}; for(int i = 1; i <= n; i++) scanf("%d",&a[i]); int maxh[MAXN]; int ans = 1; for(int i = 1; i <= n; i++){ for(int j = 1; j <= ans; j++){ if(a[i] <= maxh[j]){ maxh[j] = a[i]; break; } if(a[i] > maxh[j] && j == ans){ maxh[++ans] = a[i]; break; } } } printf("%d\n",ans-1); } return 0;}
0 0
- hdu 1257 最少拦截系统
- 最少拦截系统 hdu 1257
- HDU 1257 最少拦截系统
- HDU 1257 最少拦截系统
- HDU 1257 最少拦截系统
- hdu 1257 最少拦截系统
- HDU 1257 最少拦截系统
- hdu 1257 最少拦截系统
- HDU 1257 最少拦截系统
- hdu 1257 最少拦截系统
- hdu 1257 最少拦截系统
- hdu 1257 最少拦截系统
- hdu 1257 最少拦截系统
- HDU 1257 最少拦截系统
- HDU 1257 最少拦截系统
- HDU 1257 最少拦截系统
- hdu 1257 最少拦截系统
- hdu 1257 最少拦截系统
- Activity 中的 Dialog 创建(笔记)
- UIBezierPath CGContextSaveGState: invalid context 0x0. This is a serious error.
- ArcGIS for Server的SOE开发思路解析
- 无锁编程技术及实现
- HBase性能优化方法总结(一):表的设计
- HDU 1257 最少拦截系统
- ArcGIS for JavaScript 开发GP服务思路解析
- Wax 在 Xcode 6.1 (iOS 8.1)上的试验与摸索
- Android中的消息通知(NotificationManager和Notification)
- ArcGIS 10.3 for Desktop新特性介绍
- 复选框的选中事件
- leetcode subsets c++
- java的事件处理
- ArcGIS Server 发布带有中文标注服务乱码的问题