PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CC0000007. Đoạn bài hát không trùng (Playlist)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đoạn bài hát không trùng (Playlist)
Playlist
Source: CSES Version: Phuoc Hung OJ Extended
Problem Statement
A radio station records played songs in order, using an integer identifier for each song. Equal identifiers mean the same song. Find the maximum length of a contiguous segment in which no song occurs twice.
Input
The first line contains . The next line lists the song IDs in playback order.
Output
Print the maximum length of a contiguous duplicate-free segment.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
8
1 2 1 3 2 7 4 2
Output
5
Explanation
Positions through contain : five distinct songs.