Problem Description
Farmer John's N cows (1 <= N <= 100,000) are lined up in a row.Each cow is labeled with a number in the range 1...K (1 <= K <=10,000) identifying her breed. For example, a line of 14 cows might have these breeds:

1 5 3 2 5 1 3 4 4 2 5 1 2 3

Farmer John's acute mathematical mind notices all sorts of properties of number sequences like that above. For instance, he notices that the sequence 3 4 1 3 is a subsequence (not necessarily contiguous) of the sequence of breed IDs above. FJ is curious what is the length of the shortest possible sequence he can construct out of numbers in the range 1..K that is NOT a subsequence of the breed IDs of his cows. Help him solve this problem.

Input

• Line 1: Two integers, N and K

• Lines 2..N+1: Each line contains a single integer that is the breed ID of a cow. Line 2 describes cow 1; line 3 describes cow 2; and so on.

Output

• Line 1: The length of the shortest sequence that is not a subsequence of the input

Sample Input
14 5
1
5
3
2
5
1
3
4
4
2
5
1
2
3

Sample Output
3

0

C语言实现优先级队列——priqueue
C语言基数排序——顺序队列实现

C语言实现使用静态数组实现循环队列

C++编写优先队列打印任务
C++编写优先队列打印任务

C语言数据结构-顺序队列

C语言 优先队列

﻿﻿一、算法思想 1、根本思想：递归 2、举例设R={3，5，8，2}为需要排列的元素集合，{3，5，8，2}的全排列=3后面跟着{5,8,2}的全排列+5后面跟着{3,8,2}的全排列+8后面跟着{3,5,2}的全排列+2后面跟着{3,5,8}的全排列。对于{5,8,2}的全排列=5后面跟着{8,2}的全排列+8后面跟着{5,2}的全排列+2后面跟着{5,8}的全排列。以此类推，直到到排列只
c++中优先队列的使用（自定义排序函数）

C语言运算符的优先级排序

C语言链表实现队列操作

c#实现优先级队列
http://www.baidu.com/s?wd=c%23%E4%BC%98%E5%85%88%E7%BA%A7%E9%98%9F%E5%88%97&ie=utf-8&f=8&rsv_bp=1&rsv_idx=1&tn=baidu&rsv_pq=efc07de5000f3769&rsv_t=cfc2XQdw6vLpqMbC%2BUKjZKG3pLY5QhlmymVHc2VGh8avPmrRmgH

#include&amp;lt;stdio.h&amp;gt; #include&amp;lt;malloc.h&amp;gt; #include&amp;lt;stdlib.h&amp;gt; #define MAXQSIZE 200 typedef int QElemType; typedef struct { QElemType *base; int front; int rear; }SqQueue; voi...
[LintCode]40.用栈实现队列

C语言队列的理解