use proconio::input; use proconio::fastout; #[fastout] #[allow(non_snake_case)] fn main() { input! { (N, M): (usize, usize), A: [usize; N], } assert!(1 <= N && N <= 200_000); assert!(M <= 200_000); assert!(A.iter().all(|&x| x <= 200_000)); if M == 0 { for i in 0..N { println!("{}", N - i); } return; } let mut cnt1 = vec![0; M]; let mut cnt2 = M; let mut r = 0; let mut sum = vec![0; N+1]; for l in 0..N { while r < N && cnt2 > 0 { if A[r] < M { cnt1[A[r]] += 1; if cnt1[A[r]] == 1 { cnt2 -= 1; } } r += 1; } if r == N && cnt2 > 0 { break; } let len = r - l - 1; sum[len] += 1; sum[N-l] -= 1; if A[l] < M { cnt1[A[l]] -= 1; if cnt1[A[l]] == 0 { cnt2 += 1; } } } for i in 0..N { println!("{}", sum[i]); sum[i+1] += sum[i]; } }