Impressive Graphs
시간 제한2초메모리 제한256 MB
서로 다른 n개의 월별 매출 값을 순서대로 받고, 위치가 겹치지 않는 k개의 증가 부분수열을 골라 사용한 값의 총 개수를 최대로 만든 뒤 그중 하나를 출력한다.
문제
One of Sophie's tasks as a sales department employee is creating graphs of sales volumes. She has access to all the data, namely the integer sales volumes from the last months. Having glanced at the figures already, she knows that these numbers are pairwise different. The snag is that Sophie's boss expects impressive graphs, and not one but of them! A graph is impressive if the sequence of sales volumes in it is increasing. While Sophie can create empty graphs, she cannot get too creative. Namely, she has to conform with the following rules:
- any month's sales volume can be used in at most one graph;
- each graph must be in chronological order, i.e., for each pair of months in the graph, the earlier of the two months (and its corresponding sales volume) comes first.
The more sales volumes are used in a set of graphs, the more impressive it is.
Help Sophie in finding the most impressive set of graphs. That is, write a program that will: read the number of sales volumes, the number of sales graphs to be created, and the monthly sales volumes themselves, determines the most impressive set of sales graphs, and prints it to the standard output. If the most impressive set of sales graphs is not unique, your program may choose any of them.
입력
In the first line of input, there are two integers and (, ), separated by a single space. These specify the number of sales volumes and the number of graphs, respectively. In the second (and last) line of input, there are pairwise different integers (), separated by single spaces. These are the sales volumes from successive months.
출력
Your program should print exactly lines. The first line should contain a single integer: the maximum number of sales volumes that can be used in a set of impressive graphs. The next lines should describe those graphs, one per line. A single description should consist of an integer () --- the number of sales volumes in the graph --- followed by these volumes, i.e., integers such that and . All these numbers are separated by single spaces.
힌트
In first sample, the plots in the most impressive set of plots both have sales volumes: in one plot and in the other.