HDU 1257 最少拦截系统
来源:互联网 发布:仿猪八戒源码 编辑:程序博客网 时间:2024/06/01 15:52
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1257
贪心解法:
#include<stdio.h>int a[3005],vist[3005];int main(){int i,n,count,temp,j;while(scanf("%d",&n)!=EOF){for(i=0;i<n;i++){scanf("%d",&a[i]);vist[i] =0;}count = 0;for(i=0;i<n;i++){if(!vist[i]){temp = a[i];count++;vist[i] = 1;for(j=i+1;j<n;j++){if(a[j] <= temp && !vist[j] ){temp = a[j];vist[j]=1;}}}}printf("%d\n",count);}return 0;}
求最长递增序列
#include<stdio.h>int a[3005],dp[3005];int main(){int i,n,res,j;freopen("a.txt","r",stdin);while(scanf("%d",&n)!=EOF){for(i=0;i<n;i++)scanf("%d",&a[i]);res = -1;for(i=0;i<n;i++){dp[i] = 1;for(j=0;j<i;j++)if( a[i] > a[j] && dp[i] < dp[j]+1){dp[i] = dp[j]+1;if ( dp[i] > res)res = dp[i];}}printf("%d\n",res);}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 最少拦截系统
- 委托与事件小结——转载
- JAVA程序获取Tomcat的运行状态
- ibatis实战之一对多关联
- 如何配置IIS服务器
- Reverse Integer
- HDU 1257 最少拦截系统
- nutch-1.7-学习笔记(1)-org.apache.nutch.crawl.Injector.java-Configuration
- Linux系统编程(7)—— 进程之进程概述
- HDU 1671 Phone List 字典树
- Uva 10719 - Quotient Polynomial (多项式求解)
- 一个c回调函数的例子
- 博客 iOS 自动化测试常用语句
- WebView中的视频全屏的相关操作
- main.obj : error LNK2001: unresolved external symbol "public: bool __thiscal