codeforces 846A Curriculum Vitae(LIS)
来源:互联网 发布:数据统计方法 编辑:程序博客网 时间:2024/06/05 02:02
A. Curriculum Vitae
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Hideo Kojima has just quit his job at Konami. Now he is going to find a new place to work. Despite being such a well-known person, he still needs a CV to apply for a job.
During all his career Hideo has produced n games. Some of them were successful, some were not. Hideo wants to remove several of them (possibly zero) from his CV to make a better impression on employers. As a result there should be no unsuccessful game which comes right after successful one in his CV.
More formally, you are given an array s1, s2, …, sn of zeros and ones. Zero corresponds to an unsuccessful game, one — to a successful one. Games are given in order they were produced, and Hideo can’t swap these values. He should remove some elements from this array in such a way that no zero comes right after one.
Besides that, Hideo still wants to mention as much games in his CV as possible. Help this genius of a man determine the maximum number of games he can leave in his CV.
Input
The first line contains one integer number n (1 ≤ n ≤ 100).
The second line contains n space-separated integer numbers s1, s2, …, sn (0 ≤ si ≤ 1). 0 corresponds to an unsuccessful game, 1 — to a successful one.
Output
Print one integer — the maximum number of games Hideo can leave in his CV so that no unsuccessful game comes after a successful one.
Examples
input
4
1 1 0 1
output
3
input
6
0 1 0 0 1 0
output
4
input
1
0
output
1
变形的LIS。不是严格递增的。
#include<cstdio>#include<iostream>#include<cstring>#include<cmath>#include<algorithm>#include<map>using namespace std;const int MAX=20000;int a[MAX];int dp[MAX];//?????i ??????int main(){ int n; while(~scanf("%d",&n)) { memset(dp,0,sizeof(dp)); for(int i=1;i<=n;i++) { scanf("%d",&a[i]); dp[i]=1; } int ans=0; for(int i=1;i<=n;i++) { for(int j=1;j<=i;j++) { if(a[i]>=a[j]) dp[i]=max(dp[i],dp[j]+1); } ans=max(ans,dp[i]); } printf("%d\n",ans/2); } return 0;}
- codeforces 846A Curriculum Vitae(LIS)
- Codeforces 846 A Curriculum Vitae(dp)
- codeforces 846A Curriculum Vitae
- Educational Codeforces Round 28 A :Curriculum Vitae
- Educational Codeforces Round 28 A. Curriculum Vitae(读懂题意后的暴力水题)
- Curriculum Vitae
- curriculum vitae
- Curriculum Vitae
- curriculum-vitae
- MY New curriculum vitae
- Codeforces Round #371 (Div. 2) E. Sonya and Problem Wihtout a Legend (DP/LIS变形)
- A New Online Computational Biology Curriculum
- [Codeforces 486E] LIS of Sequence (LIS套路)
- [Codeforces 486E] LIS of Sequence (LIS套路)
- Codeforces #323 D. Once Again... (LIS)
- Becoming a Data Scientist – Curriculum via Metromap
- codeforces_846ACurriculum Vitae
- Codeforces Round #338 (Div. 2) B. Longtail Hedgehog(LIS)
- encrypt decrypt 加密解密完整实例(密文可用密钥解密)
- Faster RCNN:RPN,anchor,sliding windows
- vue vue-resource
- BZOJ 1024 生日快乐 (dfs)
- 如何给spine骨骼动画挂载粒子特效
- codeforces 846A Curriculum Vitae(LIS)
- Spring技术内幕——依赖注入
- 小明的调查统计(二)
- spring 手动回滚一切异常
- python实现汉诺塔移动
- pat 乙级 1046. 划拳(15)
- 用django写一个静态网页
- Qtree6
- 学生管理系统总结(二)