Call an array of integers diverse if it has length at least 1 and it has at least
Given an array of
Constraints
Input Specification
The first line contains two positive integers,
Each of the next
Output Specification
Output the number of subarrays that are diverse.
Sample Input
Copy
4 2
1
2
2
2
Sample Output
Copy
3
Comments
Don't use Python - nobody has passed yet.
PY3: https://dmoj.ca/problem/acc3p1/submissions/?status=AC&language=PY3
PY2: https://dmoj.ca/problem/acc3p1/submissions/?status=AC&language=PY2
Only PyPy 3 works (rarely).
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?
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
Makes sense, thanks.
Hate TLE :-(
same :)
Same :-(