Account
GitHubFeedback
Drafts and results saved on this device
Submit on CSES.fi
CSES Problemset/Sorting and Searching

Playlist

#1141
Ask AI

Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.

Open Claude Desktop

Time limit:1.00 s
Memory limit:512 MB
Unsolved
Download Tests (.zip)

You are given a playlist of a radio station since its establishment. The playlist has a total of nn songs.

What is the longest sequence of successive songs where each song is unique?

Input

The first input line contains an integer nn: the number of songs.

The next line has nn integers k1,k2,…,knk_1,k_2,\ldots,k_n: the id number of each song.

Output

Print the length of the longest sequence of unique songs.

Constraints
  • 1≤n≤2⋅1051 \le n \le 2 \cdot 10^5
  • 1≤ki≤1091 \le k_i \le 10^9
Sample Test Cases (1)
Example 1ID: sample-1
Input
8
1 2 1 3 2 7 4 2
Expected Output
5
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|1 line, 0 chars
Test Bench
Download .zip
Input (stdin)
8
1 2 1 3 2 7 4 2
Expected Output
5