NumberEater
Time limit1sMemory limit128 MB
Count the number of distinct value sets obtainable as the set of a contiguous subarray of the given sequence.
- Level
Medium6 of 10
- Topics
- Hash map, Array, Two pointers
- Solved
- No attempts yet
Problem
NumberEater is a famous monster from Byteland. It eats numbers, but it is very picky: every day its meal must be unique. The monster is given a sequence of integers . It chooses a start position and an end position () and prepares a meal made of the elements .
The monster considers two meals and to be identical when they contain the same set of numbers, that is:
Help NumberEater count how many different meals it can prepare using the sequence .
Input
The first line contains one integer (), the length of the sequence . Each of the next lines contains one element of the sequence. Every element is at least and at most .
Output
Print a single integer: the number of different meals that NumberEater can prepare.