Lazy Sorting
시간 제한1초메모리 제한1024 MB
상자끼리의 비교 결과만 주어질 때, 처음 M명의 학생에게 상자를 나눠주기 위해 필요한 최소 저울질 횟수를 구한다.
문제
Teacher Laur organized a programming contest for his students and now wants to award them prizes according to their results. The prizes were lined up on a shelf in correct order, but then Toots toppled the shelf with his horseplay. As the prizes are in identical boxes, the teacher put them back on the shelf in a random order.
The prizes have different weights and the teacher has balance scales that he can use to compare two boxes and find out which is intended for the student with the better result. However, each weighing takes time and the first students have already lined up behind his door to receive their prizes...
To minimize the total time that students spend waiting for their prizes, the teacher wants to give each student their prize with as few weighings as possible. Write a program to help the teacher do that.