ByteCompany has a server cluster with m workers, k of which are somehow disconnected.
The task scheduler have just received n tasks, and the i-th task needs to be executed on ti workers.
For an executive order of p1,p2,…pn, the task scheduler will assign workers for them respectively. Specifically, for the i-th task pi, the scheduler will select tpi workers randomly from all workers which hasn't been assigned tasks at this moment. Each of those free workers share a universal equal probability to be selected. Note that disconnected workers may also be selected. In this scenario, the current scheduling will be considered as a failure and retry automatically and immediately. Only when the scheduling of the current task is successful, the next task will be proceeded.
Now you need to find an optimal executive order of p1,p2,…pn to minimize the expected amount of the scheduling process. We guarantee that the amount of connected workers is enough to finish all scheduling.