Another Contest 3 Problem 1 - Diverse Arrays

View as PDF

Submit solution


Points: 7
Time limit: 0.3s
Memory limit: 256M

Problem type

Call an array of integers diverse if it has length at least 1 and it has at least K distinct integers.

Given an array of N integers and a parameter K, compute the number of subarrays that are diverse.

Constraints

1 \le K \le N \le 10^6

1 \le a_i \le N

Input Specification

The first line contains two positive integers, N and K.

Each of the next N lines contains a positive integer, a_i. These integers in order comprise the array.

Output Specification

Output the number of subarrays that are diverse.

Sample Input

4 2
1
2
2
2

Sample Output

3

Comments