Bessie's Interview
시간 제한2초메모리 제한1024 MB
N마리의 소와 K명의 면접관이 있을 때, 각 소의 면접 시간이 주어지면 N+1번 소인 Bessie의 면접 시작 시각과 그녀를 면접할 수 있는 면접관을 구한다.
문제
Bessie is looking for a new job! Fortunately, farmers are currently hiring and conducting interviews. Since jobs are highly competitive, the farmers have decided to number and interview cows in the order they applied. There are cows that applied before Bessie, so her number is ().
The interview process will go as follows. At time , farmer will start interviewing cow for each . Once a farmer finishes an interview, he will immediately begin interviewing the next cow in line. If multiple farmers finish at the same time, the next cow may choose to be interviewed by any of the available farmers, according to her preference.
For each , Bessie already knows that cow 's interview will take exactly minutes (). However, she doesn't know each cow's preference of farmers.
Since this job is very important to Bessie, she wants to carefully prepare for her interview. To do this, she needs to know when she will be interviewed and which farmers could potentially interview her. Help her find this information!
입력
The first line of the input will contain two integers and .
The second line will contain integers .
출력
On the first line, print the time Bessie's interview will begin.
On the second line, a bit string of length , where the -th bit is if farmer could interview Bessie and otherwise.