Educational Codeforces Round 28 A :Curriculum Vitae

本文介绍了一个游戏开发者如何通过调整自己的游戏作品列表来优化简历的方法,确保不会出现失败的作品紧随成功作品之后的情况,从而给雇主留下更好的印象。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Curriculum Vitae

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 producedn 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 arrays1, 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 numbern (1 ≤ n ≤ 100).

The second line containsn space-separated integer numberss1, 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.




  题意:  计算数列中删去某几个数使满足 没有 0出现在 1 后面所剩余的最大数组是size。

 

 思路:   昨天看足球没做,今天早上补一下。

  考虑到  数组中 没有  0 出现在 1 后面, 不仅只删除 0  ,也可以删除1 ,毕竟 要求的是  最大的size.

想了半天,WA 了两发,突然想到其实就是找出 数列中前面全是是 0  ,后面全是 1  的最大情况。  然后暴力枚举一遍就行。





#include<bits/stdc++.h>
using namespace std;


int A[1000];
int n;
int main()
{
    while(scanf("%d",&n)!=EOF)
    {
        memset(A,0,sizeof A);
        for(int i=0;i<n;i++)
        scanf("%d",&A[i]);
        int ans = 0;
        int cnt = 0;
        for (int i = 0; i <= n; ++i)
        {
            int cnt = 0;
            for (int j = 0; j < i; ++j)
            {
                if(A[j]==0)
                    cnt++;
            }
            for (int j = i; j < n; ++j)
            {
                if(A[j]==1)
                    cnt++;
            }
            ans = max(ans, cnt);
        }
        cout<<ans<<endl;
    }
    return 0;
}






 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值