PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SRD0000069. Cho đến khi tôi gục ngã (Till I Collapse)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Cho đến khi tôi gục ngã (Till I Collapse)
Till I Collapse
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
For every , partition the entire array of colors into the minimum number of nonempty contiguous segments, with at most distinct values in each segment. Every element must belong to exactly one segment.
Input
Read and the colors. There is no query section.
Output
Print integers on one line, one minimum partition count for each .
Subtasks
- Subtask 1 (10 points): . .
- Subtask 2 (20 points): . .
- Subtask 3 (30 points): . .
- Subtask 4 (40 points): . .
Examples
Input
5
1 3 4 3 3
Output
4 2 1 1 1
Explanation
For , a minimum partition is (four segments). For , uses two. For any , all elements fit into a single segment.