9043: Go to Play Maimai DX

内存限制:128 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:7 通过:6

题目描述

Ran loves playing Maimai DX. However, to play it, she needs to perpare a big bottle of water, a pair of gloves, an earphone and some coins. She wants to play Maimai DX as soon as possible, but she has to take enough coins.
So here's the Maimai DX Problem:
Given an array aaa guaranteed that 1≤ai≤41\le a_i\le 41ai4 and an integer kkk. Let's call an interval [l,r][l,r][l,r] good if it contains all 444 kinds of numbers. Try to find the shortest good interval with at least kkk 444s in it, and output it's length.
It's guaranteed that there're at least one “111”s, "222"s and "333"s in aaa. Also, there're at least kkk "444"s. That means, there'll be at lease one good intervals in aaa.

输入格式

The first line contains two integers nnn and kkk (1≤k≤n≤1051\le k\le n\le 10^51kn105), nnn means aaa's length.
The next line contains nnn integers, the iii-th one means aia_iai (1≤ai≤41\le a_i\le 41ai4).

输出格式

One integer, means the length of the shortest good interval with at least kkk 444s in it.

输入样例 复制

6 2
4 1 1 4 2 3

输出样例 复制

6