Distinct Subarray
View as PDF
Submit solution
Points:
2.00
Time limit:
1.0s
Memory limit:
512M
Input:
stdin
Output:
stdout
Author:
Problem source:
Problem types
Attempt
Please login to see your submissions result.
Last updated: on Dec. 16, 2024, 8:56 a.m.
Problem
Given an array ~A~ of ~N~ integer elements ~A_1, A_2, \dots, A_N~, count the number of subarrays where no value appears more than once.
For example, the subarray ~(3, 2, 3)~ is not valid because the value ~3~ appears twice.
Input
First line contain positive integer ~N~.
Next line contains ~N~ integers of ~A~.
Output
Print a single positive integer as the result of number of subarray that satisfied condition.
Constraints
~1 \leq N \leq 10^5~.
Sample
| Sample Input | Sample Output |
|---|---|
|
4
1 2 1 2
|
7
|
Explanation
In the first sample test, there are 7 subarrays that satisfied condition: ~(1), (2), (1), (2), (1, 2), (2, 1), (1, 2)~.
Comments