Bessie's Interview

시간 제한2초메모리 제한1024 MB

요약
N마리의 소와 K명의 면접관이 있을 때, 각 소의 면접 시간이 주어지면 N+1번 소인 Bessie의 면접 시작 시각과 그녀를 면접할 수 있는 면접관을 구한다.
난이도

보통10점 중 7점

유형
시뮬레이션, 힙, 그리디, 구현
정답자
아직 제출이 없습니다

문제

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 (1≤K≤N≤3⋅1051 \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 1≤i≤K1 \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 1≤i≤N1\le i\le N, Bessie already knows that cow ii's interview will take exactly t_it\_i minutes (1≤t_i≤1091 \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 t_1…t_Nt\_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

  1. 예제 1

    입력
    6 3
    3 1 4159 2 6 5
    
    예상 출력
    8
    110