UVA 111
来源:互联网 发布:mac chrome 书签备份 编辑:程序博客网 时间:2024/05/22 04:40
这题简直不要这么难以理解,具体翻译可以看NOCOW上给出的翻译:http://www.nocow.cn/index.php/UVA/111。
理解题意之后很明显是一个球最长上升子序列的dp问题,定义状态dp(i) 为第i个答案能和之前给出的答案组合得到的最高分,那么状态转移方程为dp(i)=max{dp(j)}+1 (0<=j<i)。
#include <iostream>#include <cstring>using namespace std;int main(){int n,r[30]={0},ss[30]={0},dp[30]={0};cin>>n;for(int i=1;i<=n;i++) cin>>r[i];int temp;while(cin>>temp){int ans=0;ss[temp]=1;for(int i=2;i<=n;i++){cin>>temp;ss[temp]=i;}for(int i=1;i<=n;i++){int Max=0;for(int j=0;j<i;j++) if(r[ss[i]]>r[ss[j]]){if(dp[j]>Max) Max=dp[j];}dp[i]=Max+1;if(dp[i]>ans) ans=dp[i];}cout<<ans<<endl;}return 0;}
0 0
- UVa 111
- UVa 111
- uva-111
- UVA 111
- uva 111
- UVA 111
- UVa 111 - History Grading
- uva 111 History Grading
- [UVA 111] History Grading
- uva:111 - History Grading
- UVa 111 - History Grading
- UVa 111 - History Grading
- UVA 111 History Grading
- UVa 111 - History Grading
- Uva - 111 - History Grading
- UVa 111 - History Grading
- UVa 111 - History Grading
- Uva-111-History Grading
- mac 下git命令自动补全设置
- erlang iolist
- EF-实体对象建立Dome
- 【Android 应用开发】 自定义组件 宽高适配方法, 手势监听器操作组件, 回调接口维护策略, 绘制方法分析 -- 基于 WheelView 组件分析自定义组件
- effective c++ 条款03 整理
- UVA 111
- 谈Qt经典出错信息之QApplication: No such file or directory
- 2.1 JavaScript基础学习笔记.JSp1
- jsp中将链接http传递中文数据至action中发生乱码现象的解决
- linux (centos) 安装tomcat (用shell脚本安装为服务)
- 20141126
- Unable to load bean: type: class:com.opensymphony.xwork2.ObjectFactory - bean - jar:file 2010-08-03
- 精通QTP-自动化测试技术领航 第2章2.2.9综合实例练习总结
- java项目部署文件快速提取