문제
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.
예제 입력 1
6 3
3 1 4159 2 6 5
예제 출력 1
8
110
점수
Inputs 2-3: No two farmers finish at the same time.Inputs 4-9: Inputs 10-21: No additional constraints.
코드를 제출하려면 로그인이 필요합니다.
로그인