There are M male students, N female students, and a teacher in a classroom.
The teacher wants to compute the total amount of money in the classroom by a "reduction" procedure.
A student tells his/her amount of money to another student (or to the teacher).
The receiver computes the sum, and relay the information to the next receiver.
For the reduction procedure:
Everyone can only speak to one person, everyone can only listen to one person,
and no one can speak and listen at the same time.
It takes A seconds for a female student to tell a number, and B seconds for a male student.
Given A, B, N, M, find the least time if there is a way to do this.
There are four numbers A, B, N, M. For all test cases, 1<=A<B<=10000 and 0<=N,M<=200
Output the least amount of time.
原TIOJ1534 / ACP 2009 期末考前練習。 Problem setter: Tmt.
|No.||Time Limit (ms)||Memory Limit (KiB)||Output Limit (KiB)||Subtasks|