Logo
(追記) (追記ここまで)

31769번 - Bessie's Interview 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB247715727.941%

문제

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

The interview process will go as follows. At time 0ドル,ドル farmer $i$ will start interviewing cow $i$ for each 1ドル \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ドル\le i\le N,ドル Bessie already knows that cow $i$'s interview will take exactly $t_i$ minutes (1ドル \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 $N$ and $K$.

The second line will contain $N$ integers $t_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 $K,ドル where the $i$-th bit is 1ドル$ if farmer $i$ could interview Bessie and 0ドル$ otherwise.

제한

예제 입력 1

6 3
3 1 4159 2 6 5

예제 출력 1

8
110

There are 6ドル$ cows aside from Bessie and 3ドル$ farmers, and the interview process will go as follows:

  1. At time $t = 0,ドル farmer 1ドル$ interviews cow 1ドル,ドル farmer 2ドル$ interviews cow 2ドル,ドル and farmer 3ドル$ interviews cow 3ドル$.
  2. At time $t = 1,ドル farmer 2ドル$ finishes his interview with cow 2ドル$ and starts interviewing cow 4ドル$.
  3. At time $t = 3,ドル both farmer 1ドル$ and farmer 2ドル$ finish their interviews, and there are two possibilities:
    • Farmer 1ドル$ interviews cow 5ドル$ and farmer 2ドル$ interviews cow 6ドル$. In this case, farmer 2ドル$ would finish his interview at time $t = 8$ and start interviewing Bessie.
    • Farmer 1ドル$ interviews cow 6ドル$ and farmer 2ドル$ interviews cow 5ドル$. In this case, farmer 1ドル$ would finish his interview at time $t = 8$ and start interviewing Bessie.

Thus, Bessie's interview will begin at time $t = 8,ドル and she could be interviewed by either farmer 1ドル$ or farmer 2ドル$.

힌트

출처

Olympiad > USA Computing Olympiad > 2023-2024 Season > USACO 2024 US Open Contest > Silver 1번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /