Question:
There are n people performing health check. Each person needs to check k items and m doctors. It takes 1 minute for each doctor to check one item for each person, how long does it take to check all the people. Requirement: each doctor can only check one project for one person at a time, and each person can only receive one doctor to check one project at a minute.
Solution:
It is easy to think of binary.
Everyone has k projects. Obviously, the minimum time is k minutes. If it is smaller than k, one person will check more than two projects at the same minute.
Consider the worst case. It takes n * k minutes for only one doctor.
Then, for the first doctor, we can construct it in this way. His mid minute checks a11, a12, a13, a1k and then a2 (k + 1 )..... a2mid, and so on. In this way, the sequence of doctor visits can be given. Of course, the number of check items for each person can also be different.
For details, see the code:
[Cpp]
SPAN style = "FONT-SIZE: 18px" >#include <iostream>
# Include <cmath>
# Include <cstdio>
# Include <cstdlib>
# Include <string>
# Include <cstring>
# Include <algorithm>
# Include <vector>
# Include <map>
# Include <stack>
# Include <list>
# Include <queue>
# Define eps 1e-6
# Define INF (1 <30)
# Define PI acos (-1.0)
Using namespace std;
Int main ()
{
Int t, n, k, m;
Scanf ("% d", & t );
While (t --)
{
Scanf ("% d", & n, & k, & m );
Int left = k, right = n * k, mid, ans;
While (left <= right)
{
Mid = (left + right)/2;
If (mid * m> = n * k) // you can check all the patients.
{
Ans = mid;
Right = mid-1;
}
Else
Left = mid + 1;
}
Printf ("% d \ n", ans );
}
Return 0;
}
</SPAN>
# Include <iostream>
# Include <cmath>
# Include <cstdio>
# Include <cstdlib>
# Include <string>
# Include <cstring>
# Include <algorithm>
# Include <vector>
# Include <map>
# Include <stack>
# Include <list>
# Include <queue>
# Define eps 1e-6
# Define INF (1 <30)
# Define PI acos (-1.0)
Using namespace std;
Int main ()
{
Int t, n, k, m;
Scanf ("% d", & t );
While (t --)
{
Scanf ("% d", & n, & k, & m );
Int left = k, right = n * k, mid, ans;
While (left <= right)
{
Mid = (left + right)/2;
If (mid * m> = n * k) // you can check all the patients.
{
Ans = mid;
Right = mid-1;
}
Else
Left = mid + 1;
}
Printf ("% d \ n", ans );
}
Return 0;
}