QOJ.ac

QOJ

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

#10932. 彩色弹珠

Statistics

玩具店が新しくオープンし、カラフルなビー玉が無料で配布されることになりました。小明(シャオミン)はこの機会を利用することにしました。

玩具店の店主は $n$ 個のビー玉を一列に並べました。$i$ 番目のビー玉には色 $c_i$ が付いています。小明はこのビー玉の列からある区間を一つ選び、その区間内でその色が出現回数1回のみであるビー玉だけを受け取ることができます。

小明が最大で何個のビー玉を受け取ることができるか求めてください。

入力

1行目に正整数 $n$ が与えられます。これはビー玉の個数を表します。 2行目に $n$ 個の整数がスペース区切りで与えられ、$i$ 番目の数はビー玉の色 $c_i$ を表します。

出力

小明が受け取ることができるビー玉の最大数を1つの整数で出力してください。

入出力例

入力 1

10
1 2 3 6 6 3 7 9 8 8

输出 1

5

注記 1

区間 $[1, 9]$ を選ぶと、色 1、2、7、8、9 のビー玉をそれぞれ1つずつ、計 5 個受け取ることができます。色 3 と 6 のビー玉は区間内で2回出現しているため、受け取ることはできません。

小課題

$30\%$ のデータについて、$n \le 10^3$ を満たす。

$100\%$ のデータについて、$n \le 3 \times 10^5$、$1 \le c_i \le n$ を満たす。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.