UVA - 111 History Grading
来源:互联网 发布:网络 士多 编辑:程序博客网 时间:2024/04/29 10:36
dp做的第一题。。。额,要注意题目,排序还稍有点复杂。。。。
#include<cstdio>#include<cstring>#include<algorithm>#define MAX 30using namespace std;int s[MAX],t[MAX],dp[MAX],s1[MAX],t1[MAX];int main(){ int n,i,j,maxx; scanf("%d",&n); memset(s,0,MAX*4); for(i=1;i<=n;i++) { scanf("%d",&s[0]); s[s[0]]=i; } for(i=1;i<=n;i++) s1[s[i]]=i; while(~scanf("%d",&t[0])) { memset(dp,0,MAX*4); t[t[0]]=1,maxx=1; for(i=2;i<=n;i++) { scanf("%d",&t[0]); t[t[0]]=i; } for(i=1;i<=n;i++) t1[i]=s1[t[i]]; dp[1]=1; //for(i=1;i<=n;i++) // printf("%d ",t1[i]); for(i=2;i<=n;i++) { for(j=1;j<i;j++) { if(t1[j]<t1[i]) dp[i]=max(dp[i],dp[j]+1); } if(dp[i]==0) dp[i]=1; maxx=max(dp[i],maxx); } //for(i=1;i<=n;i++) // printf("%d ",dp[i]); printf("%d\n",maxx); } return 0;}
0 0
- 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
- UVa 111: History Grading
- UVA - 111 History Grading
- UVA 111 History Grading
- uva 111History Grading
- UVA 111 History Grading
- UVA-111 History Grading
- .\test.sct(5): error: L6236E: No section matches selector - no section to be FIRST/LAST.
- 坦克大战
- 使用URL实现和站点的交互
- cocos2d-x内存管理注意事项
- Java内存区域与内存溢出异常
- UVA - 111 History Grading
- HDU2552 三足鼎立
- 指针参数如何传递内存(写的很好)
- javascript 数组,数组中添加新元素 push() ,unshift() 相当于Add()
- dom4j读取某个元素的某个属性
- 白乔原创:程序员的路该怎么走?
- [译文]JOAL教程 第二课 循环与淡出
- dom4j解析xml字符串实例
- 自考颗粒归仓-----数据库原理概况