LRU
题号:NC229318
时间限制:C/C++/Rust/Pascal 3秒,其他语言6秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

It costs a long time for CPUs to access data from memory, so most of CPUs have caches where requests for data can be served faster. To be cost-effective and to enable efficient use of data, caches must be relatively small. Therefore, we must use some policies to choose some data wisely and storage them in the cache.
We divide the memory into many blocks which have the same size and index them from 1 to , and every block has an unique index. A cache will have a capacity for K blocks, which means it can storage at most K blocks simultaneously.
A cache hit occurs when the requested block is available in the cache, or we say a cache miss occurs.
Now we introduce a LRU (Least Recently Used) placement policy on a fully associative cache.

  • If the requested block is available in the cache, a cache hit occurs.
  • If not, CPU can only access the block from the memory and write the block into the cache. If cache is not full, append the block into the cache.
  • If the cache is full, cache is full, the block which haven't been visited for the longest time in the cache will be replaced by the new block.


An example for cache with capacity of 3 blocks is shown below.



The , and are in the cache when the block is requested, so a cache miss occurs. At that time, the cache is full, and we must decide the block to be replaced. The most recent request of block is the request, the most recent request of block is the request and the most recent request of block is the request. The block will be replaced by the block because the block hasn't been visited for longest time.

Now the sequence of requested blocks and the capacity of the cache are given, please determine the minimum capacity for the cache in order to ensure at least K requests to hit the cache.

输入描述:

The first line contains two numbers N and , denoting the length of sequence and the number of requests required to be hit.
The second line contains N integers and the number denoting the index of block requested by the request.

输出描述:

The output contains only one line.
If it is possible to enable at least K requests to be hit by the cache, then output a single integer denoting the smallest capacity in blocks, or output "cbddl" (without quotes).
示例1

输入

复制
15 6
3 4 2 6 4 3 7 4 3 6 3 4 8 4 6

输出

复制
3
示例2

输入

复制
15 5
3 4 2 6 4 3 7 4 3 6 3 4 8 4 6

输出

复制
3
示例3

输入

复制
15 10
3 4 2 6 4 3 7 4 3 6 3 4 8 4 6

输出

复制
cbddl