시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 512 MB | 45 | 17 | 17 | 43.590% |
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 1 unit of blood. Each patient’s blood type determines the type of blood s/he may receive:
Patients who have Rh-negative blood can accept Rh-negative blood only, but patients with Rhpositive 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?
The first line of input contains 8 integers: the number of units of blood of Type O negative, O positive, A negative, A positive, B negative, B positive, AB negative and AB positive. This is followed by a line containing eight numbers: the number of patients whose blood type is O negative, O positive, A negative, A positive, B negative, B positive, and AB negative and AB positive. Each of these integers will be at least 0 and less than 107 .
The output of your program should be a single number: the maximum number of patients that can receive blood.
5 5 3 1 2 11 5 12 2 4 9 2 3 9 7 3
33