Under construction

Still being built. Things may change

Bessie's Interview

Time limit2sMemory limit1024 MB

Summary
Given K farmers and N cows with interview durations, find when cow N+1 starts her interview and which farmers could interview her.
Level

Medium7 of 10

Topics
Heap, Union-find, Simulation
Solved
No attempts yet

Problem

Bessie is looking for a new job! Luckily, KK farmers are hiring right now and holding interviews. Jobs are very competitive, so the farmers have decided to number the cows in the order they applied and interview them in that order. 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 works as follows. At time 00, farmer ii starts interviewing cow ii for each 1≤i≤K1 \leq i \leq K. When a farmer finishes an interview, he immediately starts interviewing the next cow in line. If several farmers finish at the same time, the next cow may be interviewed by any of the available farmers, of her choice.

For each 1≤i≤N1 \leq i \leq N, cow ii's interview takes exactly tit_i minutes (1≤ti≤1091 \leq t_i \leq 10^9). Bessie knows these values, but she does not know which farmer each cow prefers.

Bessie wants to prepare carefully. She needs to know when her interview begins and which farmers could interview her. Find this information.

Input

The first line contains two integers NN and KK.

The second line contains NN integers t1…tNt_1 \dots t_N.

Output

On the first line, print the time at which Bessie's interview begins.

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

Examples1

  1. Example 1

    Input
    6 3
    3 1 4159 2 6 5
    
    Expected output
    8
    110