题解-[USACO 2013 Jan]Cow Lineup

这是一篇关于USACO竞赛中Cow Lineup问题的题解,主要内容是帮助Farmer John确定通过移除最多K个不同编号的牛,如何能形成最大的连续相同编号牛的序列。文章包括问题描述、输入输出样例、解题思路和代码实现。
摘要由CSDN通过智能技术生成

题目描述

Description

Cow Lineup [Brian Dean and Daniel Dara, 2012] Farmer John’s N cows
(1 <= N <= 100,000) are lined up in a row. Each cow is identified
by an integer “breed ID” in the range 0…1,000,000,000; the breed
ID of the ith cow in the lineup is B(i). Multiple cows can share the
same breed ID. FJ thinks that his line of cows will look much more
impressive if there is a large contiguous block of cows that all have
the same breed ID. In order to create such a block, FJ chooses up to K
breed IDs and removes from his lineup all the cows having those IDs.
Please help FJ figure out the length of the largest consecutive block
of cows with the same breed ID that he can create by doing this.
有N头牛(1 <= N <= 100,000) 排成一列。每头牛有一个标号,范围在0到1000000000,
第 i 头牛的编号为B(i)。多头牛可以共享一个编号。John想,如果前后相邻的多头牛

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值