## Another Contest 3 Problem 1 - Diverse Arrays

View as PDF

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 distinct integers.

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

#### Input Specification

The first line contains two positive integers, and .

Each of the next lines contains a positive integer, . 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

• commented on Aug. 25, 2022, 5:19 p.m. edit 5

Don't use Python - nobody has passed yet.

Only PyPy 3 works (rarely).

• commented on June 1, 2019, 12:52 p.m.

So {1, 2, 2, 2} has subarrays with 2 or more elements:

{1, 2}

{2, 2}

{2, 2}

{1, 2, 2}

{1, 2, 2, 2}

but only {1, 2} is an array of distinct integers.... Am I missing something here? is distinct the wrong adjective or is the sample case wrong?

• commented on June 1, 2019, 4:01 p.m.

You are looking for subarrays with at least distinct integers

{1, 2}, {1, 2, 2}, {1, 2, 2, 2} all work because they contain integers 1 and 2

• commented on June 1, 2019, 7:19 p.m.

Makes sense, thanks.

• commented on Dec. 25, 2018, 1:19 a.m. edited

Hate TLE :-(

• commented on Nov. 24, 2020, 5:53 a.m.

same :)

• commented on Nov. 24, 2020, 5:52 a.m.

Same :-(