zoukankan
html css js c++ java
hdu1160最长递增子序列
//1160 #include <iostream> #include <algorithm> using namespace std; struct mouse { int id; int weight; int speed; int pos; int pre; }s[10005]; bool cmp(mouse a,mouse b) { return(a.weight<b.weight||(a.weight==b.weight&&a.speed<b.speed)); } int main() { int count=0; while(scanf("%d %d",&s[count].weight,&s[count].speed)!=EOF) { s[count].id=count+1; count++; } sort(s,s+count,cmp); /*********************************************************************************/ //最长递增子序列部分 int ans[10005]={0}; s[0].pos=1; int i,j,max=1,maxi=0; //记录每个点的序列位置 for(i=1;i<count;i++) { j=max; while(j) { if(s[i].weight>s[ans[j]].weight&&s[i].speed<s[ans[j]].speed) { s[i].pos=j+1; ans[j+1]=i; s[i].pre=ans[j]; break; } j--; } //第一个点 if(j==0) { s[i].pos=1; ans[1]=i; } //目前为止最长的点 if(s[i].pos>max) { max=s[i].pos; maxi=i; } } /* for(int cc=0;cc<count;cc++) cout<<cc<<' '<<s[cc].id<<' '<<s[cc].weight<<' '<<s[cc].speed<<' '<<s[cc].pos<<' '<<s[cc].pre<<endl; */ cout<<max<<endl; //输出最长序列 int temp[10005]; for(i=1;i<=max;i++) { temp[i]=s[maxi].id; maxi=s[maxi].pre; } for(i=max;i>0;i--) cout<<temp[i]<<endl; /*********************************************************************************/ return 0; }
查看全文
相关阅读:
VS的代码分析工具
时间管理-SMART原则
时间管理-该怎样进行时间管理
ASP.NET Identity V2
SQL Server 事务隔离级别的查看及更改
GAC(Global Assembly Cache)注册/卸载 dll
基于小米即时消息云服务(MIMC)的Web IM
Spring Boot MyBatis配置多种数据库
解决easyui combobox赋值boolean类型的值时,经常出现的内容显示的value而不是text的bug
thymeleaf-extras-db 0.0.1发布,select标签加载数据的新姿势
原文地址:https://www.cnblogs.com/windmissing/p/2559896.html
最新文章
sql
sql中的聚合函数
list列表
苹果手机连接fiddler
Python字符串
Jmeter http请求—content-type与参数
用jenkins生成文档:No plugin found for prefix 'javadoc' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories
Compact Middle Packages
SpringBoot使用mybatis,发生:Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured
使用StringBuilder构建字符串
热门文章
解决使用RabbitTemplate操作RabbitMQ,发生The channelMax limit is reached. Try later.问题
在虚拟机环境(CentOS7系统)下将kubernetes中部署服务成功,但在虚拟机外部无法访问到服务
使用dockerfile-maven-plugin发布docker到私有仓库
idea无法下载源码(Cannot download sources)
解决Spring Boot(2.1.3.RELEASE)整合spring-data-elasticsearch3.1.5.RELEASE报NoNodeAvailableException[None of the configured nodes are available
为docker设置国内镜像
ASP.NET Core环境配置
Centos 安装 Nodejs
重新组织 vs 重新生成索引
RosettaNet
Copyright © 2011-2022 走看看