10286_ClassPacking

2022-5-16 18:16| 发布者: Hocassian| 查看: 58| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-3-89504730413200-Problem List-采集的数据-后羿采集器.html

Pro.ID

10286

Title

Class Packing

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=10286

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 4000/2000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    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:

    • classes with kindergarten to year 2 pupils must have a size of 20 or less,

    • classes with year 3 and year 4 pupils must have a size of 25 or less,

    • classes with year 5 and year 6 pupils must have a size of 30 or less,

    • a class can only have pupils from one grade or two consecutive grades; for example, a class with Kindergarten and year 1 pupils must have a size of 20 or less, while a class with year 4 and year 5 pupils must have a size of 25 or less.

    • one teacher must be assigned to one, and only one, class.

    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.

    输出

    Description

    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:

    • classes with kindergarten to year 2 pupils must have a size of 20 or less,

    • classes with year 3 and year 4 pupils must have a size of 25 or less,

    • classes with year 5 and year 6 pupils must have a size of 30 or less,

    • a class can only have pupils from one grade or two consecutive grades; for example, a class with Kindergarten and year 1 pupils must have a size of 20 or less, while a class with year 4 and year 5 pupils must have a size of 25 or less.

    • one teacher must be assigned to one, and only one, class.

    Your task is to write a program that reads the enrolment numbers and computes the minimum number of teachers required.

    Input

    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.

    Output

    The output consists of a single line, for each test case, which contains a single integer that represents the minimum number of teachers required.

    Sample Input

    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

    Sample Output

    6
    1
    2
    2
    26
    30

    Source

    样例输入

    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

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部