시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 76 | 22 | 19 | 29.231% |
The NumberEater is a famous monster from Byteland. It eats numbers, but it is very picky: each day its meal must be unique. The monster is given a sequence of integers (an). It chooses the starting and ending positions of a meal -i and j (1 ≤ i ≤ j ≤ n) - and prepares a meal that consists of elements ai, ai+1, …, aj. The monster considers two meals [i1,j1] and [i2,j2] identical if the sets of numbers that they contain are the same; in other words:
{ak : i1 ≤ k ≤ j1} = {ak : i2 ≤ k ≤ j2}
Help NumberEater and count the number of different meals that it can prepare using only the sequence a.
The first line of the input contains one integer n (1 ≤ n ≤ 500), the length of the sequence a. The following n lines contain values of elements of the sequence. Each of them is at least 1 and at most 500.
The first and only line of the output should contain the number of different meals that NumberEater can prepare.
6 1 2 3 1 2 3
7
Camp > POI Training Camp > ONTAK 2007 10번