Logo
(追記) (追記ここまで)

32535번 - Učiteljica 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 1024 MB40221748.571%

문제

In the best school in Varaždin, there was an excellent computer science teacher known for her interesting and unusual ideas. Her name was Lana, and she often gave her students impossible or unsolvable problem. Each student only needed to solve 1 problem during the school year to pass the class with an excellent grade. Students who did not solve any tasks by the end of the year would have to repeat the grade. On the last day of school, she wrote an extremely difficult problem on the board, which went as follows:

Imagine you have a sequence of numbers of length $N,ドル and you can remove some elements from the beginning or the end (or both). How many ways can you perform such deletions so that after the deletion, there must be at least 1ドル$ number that appears exactly once, at least 1ドル$ number that appears exactly twice, . . ., and at least 1ドル$ number that appears exactly $K$ times.

A student named Fran, who had not solved any problems so far, quickly said, "I know how to solve this problem." Teacher Lana did not believe Fran and told him, "Write the code in the next 30 minutes, and then I’ll believe you. If you don’t, you’ll have to repeat the grade." Fran doesn’t know how to code, so he urgently asked for your help to write the code to solve this task. In his hurry, he forgot to explain his idea for solving the task. Write a code that takes as input the numbers $N$ and $K,ドル the sequence of $N$ elements, and solve Lana’s question to help Fran.

입력

In the first line, there are 2ドル$ positive integers $N$ (1ドル ≤ N ≤ 10^5$) and $K$ (1ドル ≤ K ≤ 4$) from the task description.

In the second line, there are $N$ positive integers $a_i$ (1ドル ≤ a_i ≤ N$), the numbers from the task description.

출력

In the first line, print a whole number, the number of distinct deletions such that the conditions from the task hold. Two deletions are different if there is an index that is not deleted in one, but deleted in the other.

제한

서브태스크

번호배점제한
120

$N ≤ 1000$

215

1ドル ≤ a_i ≤ k$ for all $i = 1, 2, \dots , N$

335

$K = 1$

450

No additional constraints.

예제 입력 1

3 1
1 2 1

예제 출력 1

6

The possible sequences after deletion are: $[1], [2], [1], [1, 2], [2, 1], [1, 2, 1],ドル and in each of the 6ドル$ sequences, there is a number that appears exactly once.

예제 입력 2

6 3
6 5 6 4 5 5

예제 출력 2

1

The only sequence after deletion in which there is at least 1ドル$ number that appears exactly once, at least 1ドル$ number that appears exactly twice, and at least 1ドル$ number that appears exactly three times is the given sequence of $N$ numbers.

예제 입력 3

6 2
5 4 5 2 6 5

예제 출력 3

5

힌트

출처

Contest > Croatian Open Competition in Informatics > COCI 2024/2025 > Contest #1 4번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /