Canadian Computing Competition: 2011 Stage 1, Senior #4
At the Canadian Cardiac Centre there are four types of blood available: O, A, B, and AB. Each of these types of blood has an Rh factor, which is either "positive" or "negative". There are many patients who each require
- Each Type O patient requires Type O blood.
- Each Type A patient may receive blood of Type A or Type O.
- Each Type B patient may receive blood of Type B or Type O.
- Each Type AB patient may receive blood of any type.
Patients who have Rh-negative blood can accept Rh-negative blood only, but patients with Rh-positive blood can accept either Rh-positive or Rh-negative types of blood.
We want as many patients as possible to receive a unit of blood. What is the maximum number of patients that can receive blood?
Input Specification
The first line of input contains
Output Specification
The output of your program should be a single number: the maximum number of patients that can receive blood.
Sample Input
5 5 3 1 2 11 5 12
2 4 9 2 3 9 7 3
Sample Output
33
Explanation for Sample Output
- 2 Type O- patients receive Type O- blood
- 4 Type O+ patients receive Type O+ blood
- 3 Type A- patients receive Type A- blood
- 3 Type A- patients receive Type O- blood
- 1 Type A+ patient receives Type A+ blood
- 1 Type A+ patient receives Type O+ blood
- 2 Type B- patients receive Type B- blood
- 9 Type B+ patients receive Type B+ blood
- 5 Type AB- patients receive Type AB- blood
- 3 Type AB+ patients receive Type AB+ blood
Comments
Can an editorial be opened for this problem?
Done. https://dmoj.ca/problem/ccc11s4/editorial
The intended solution is any maximum flow algorithm.
Since the data were weak, the original data (
test cases) were each weighed 3 marks and new, stronger data (
test cases) were added in a subtask worth another 
marks.