QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 100

#10932. 彩色弹珠

الإحصائيات

玩具店新开张,免费赠送一些彩色弹珠,小明决定来蹭这个便宜。

玩具店老板将 $n$ 个弹珠排成了一排,第 $i$ 个弹珠有一个颜色 $c_i$。小明只能从这排弹珠里选取一个区间,拿到其中仅出现了该颜色一次的弹珠。

小明想知道他最多可以拿走几颗弹珠。

输入格式

第一行一个正整数 $n$,表示有 $n$ 个弹珠。第二行 $n$ 个数用空格隔开,第 $i$ 个数表示弹珠颜色 $c_i$。

输出格式

一个数,表示小明最多能拿走的弹珠数量。

样例数据

样例 1 输入

10
1 2 3 6 6 3 7 9 8 8

样例 1 输出

5

样例 1 解释

选取 $[1,9]$ 这个区间,拿走了颜色为 1、2、7、8、9 的这 5 个弹珠。由于颜色为 3 和 6 的弹珠都出现了两次,故不能选。

子任务

对于 $30\%$ 的数据,有$n \le 10^3$。

对于 $100\%$ 的数据,有$n \le 3 \times 10^5$,$1 \le c_i \le n$

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.