시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 10 | 7 | 7 | 70.000% |
Amelia-Bedelia, the principal of the local primary school, is tired of handling the annual confusing problem on the first day of every school year. She wants her computer to solve the problem for her.
The problem is that Amelia-Bedelia finds out, on the first day of school, the number of pupils enrolled in each year from Kindergarten to year 6. She needs to put the pupils in classes in such a way that she uses the smallest number of teachers while adhering to the following Department of Education rules:
Your task is to write a program that reads the enrolment numbers and computes the minimum number of teachers required.
The input consists of a number of test cases. The description for each test case consists of seven non-negative integers on a line by themselves. The integers represent the number of pupils enrolled from Kindergarten to year 6 in that order. All integers have values less than 200, and a single space separates the integers.
A line with seven zeroes terminates the input and is not be processed.
The output consists of a single line, for each test case, which contains a single integer that represents the minimum number of teachers required.
20 20 20 20 20 20 20 19 1 0 0 0 0 0 19 0 1 0 0 0 0 19 3 0 0 0 0 0 3 48 77 165 173 165 4 125 141 107 8 68 58 176 0 0 0 0 0 0 0
6 1 2 2 26 30