codeforces 846A Curriculum Vitae
来源:互联网 发布:javascript split 编辑:程序博客网 时间:2024/05/22 11:25
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.
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.
Print one integer — the maximum number of games Hideo can leave in his CV so that no unsuccessful game comes after a successful one.
41 1 0 1
3
60 1 0 0 1 0
4
10
1
题意:给n个只含0 1的数列,可以删去任意位置的数,使的数列满足0在1的左边(即没有1在0左边),求满足条件的序列的最大长度,题目看了半天才看懂
模拟一下计算满足条件的最大值即可
#pragma comment(linker,"/STACK:1024000000,1024000000")#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<string>#include<stack>#include<queue>#include<deque>#include<set>#include<map>#include<cmath>#include<vector>using namespace std;typedef long long ll;typedef unsigned long long ull;typedef pair<int, int> PII;#define pi acos(-1.0)#define eps 1e-10#define pf printf#define sf scanf#define lson rt<<1,l,m#define rson rt<<1|1,m+1,r#define e tree[rt]#define _s second#define _f first#define all(x) (x).begin,(x).end#define mem(i,a) memset(i,a,sizeof i)#define for0(i,a) for(int (i)=0;(i)<(a);(i)++)#define for1(i,a) for(int (i)=1;(i)<=(a);(i)++)#define mi ((l+r)>>1)#define sqr(x) ((x)*(x))const int inf=0x3f3f3f3f;int n,a[110],ans;int main(){ while(~sf("%d",&n)) { ans=0; for1(i,n)sf("%d",&a[i]); for1(i,n+1)//在最后加上一个0再计算不会影响结果,防止全是0 { int cnt=0; for1(j,n) { if(j<i&&!a[j])cnt++;//小于第i位是0的情况 if(j>=i&&a[j])cnt++;//大于等于i位是1的情况 } ans=max(ans,cnt); } pf("%d\n",ans); } return 0;}
- codeforces 846A Curriculum Vitae
- Codeforces 846 A Curriculum Vitae(dp)
- codeforces 846A Curriculum Vitae(LIS)
- Educational Codeforces Round 28 A :Curriculum Vitae
- Curriculum Vitae
- curriculum vitae
- Curriculum Vitae
- curriculum-vitae
- Educational Codeforces Round 28 A. Curriculum Vitae(读懂题意后的暴力水题)
- MY New curriculum vitae
- A New Online Computational Biology Curriculum
- Becoming a Data Scientist – Curriculum via Metromap
- codeforces_846ACurriculum Vitae
- CodeForces-a
- CFA Curriculum到手
- Curriculum Vita & Application Letter
- #Paper Reading# Curriculum Learning
- WOJ1019-Curriculum Schedule
- 拓展log4j——在写日志时加入自己的逻辑.md
- Codeforces Round #419 (Div. 2)-贪心&思维-C. Karen and Game
- ubuntu搭建dns服务器
- R语言统计分析篇
- laya之坑--加密解密算法
- codeforces 846A Curriculum Vitae
- 04. Yii 2.0 的MVC模式
- Oracle获取所有的上级和下级 connect by
- My eclipse设置tab为4个空格
- 拓扑排序问题
- mysql集群——(二)环境搭建
- 如何设置vim里字体颜色
- GitChat · 人工智能 | 人工智能产品测试方法探索
- srm500