C - Colorful Candies AtCoder Beginner Contest 210

这篇博客介绍了AtCoder Beginner Contest 210中的一道题目,目标是找到Takahashi能获得的最大不同颜色糖果数。问题涉及滑动窗口和颜色计数策略,通过优化选择区间来最大化糖果颜色的多样性。
摘要由CSDN通过智能技术生成

https://atcoder.jp/contests/abc210/tasks/abc210_c

题目描述:

There are N candies arranged in a row from left to right. Each of these candies has one color that is one of the 10^9 colors called Color 1, Color 2, ……, and Color 10^9. For each i=1,2,…,N, the color of the ii-th candy from the left is Color ci.

From this row, Takahashi can choose K consecutive candies and get them. That is, he can choose an integer ii such that 1≤i≤N−K+1 and get the i-th, (i+1)-th, (i+2)-th, ……, (i+K−1)-th candy from the left.

Takahashi likes to eat colorful candies, so the more variety of colors his candies have, the happier he will be. Print the maximum possible number of distinct colors in candies he gets.

数据范围:

  • 1≤K≤N≤3×10^5

  • 1≤ci≤10^9

  • All values in input are integers.

输入:

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值