PivotOJ

Bessie's Interview

시간 제한: 2000ms메모리 제한: 1024MB출처: USACO 2024 Open SilverBOJ 31769

문제

Bessie is looking for a new job! Fortunately, KK 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 NN cows that applied before Bessie, so her number is N+1N+1 (1KN31051 \leq K \leq N \leq 3 \cdot 10^5).

The interview process will go as follows. At time 00, farmer ii will start interviewing cow ii for each 1iK1 \leq i \leq K. 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 1iN1\le i\le N, Bessie already knows that cow ii's interview will take exactly tit_i minutes (1ti1091 \leq t_i \leq 10^9). 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 NN and KK.

The second line will contain NN integers t1tNt_1 \dots t_N.

출력

On the first line, print the time Bessie's interview will begin.

On the second line, a bit string of length KK, where the ii-th bit is 11 if farmer ii could interview Bessie and 00 otherwise.

예제

예제 1

입력
6 3
3 1 4159 2 6 5
출력
8
110
코드를 제출하려면 로그인하세요.