Remix
시간 제한2초메모리 제한1024 MB
현재 multiset에서 부분집합을 골라 최댓값과 최솟값의 차로 바꾸는 연산을 반복해 마지막에 남는 정수를 최대로 만든다.
문제
You are given a multiset consisting of integers. You should perform the following three-step operation some number of times until a single integer remains in .
- Choose a multiset such that and .
- Erase the elements of from .
- Insert to .
Find a sequence of operations that maximizes the integer left in .
입력
The first line contains a single integer .
The second line contains integers .
출력
On the first line, print a single integer , the number of operations.
On each of the next lines, print an integer , the size of the chosen multiset , followed by integers, .
Note that the operations are executed in the same order they are listed. So, for each operation, must be a subset of when all the preceding operations are performed.
힌트
The sample does the following operations:
The values underlined in denote the integer inserted. After the fourth operation, is reduced to a single integer value of . It can be shown that no other sequence of operations results in a larger value.