首页 > 代码库 > HDU 4406 GPA

HDU 4406 GPA

GPA

Time Limit: 1000ms
Memory Limit: 32768KB
This problem will be judged on HDU. Original ID: 4406
64-bit integer IO format: %I64d      Java class name: Main
 
GPA(Grade-Point Average) is one way to measure students’ academic performance in PKU. Each course has an integer credit, ranges from 1 to 99. For each course, you will get a score at the end of the semester, which is an integer ranges from 0 to 100. Then you can calculate the Grade-Point of this course with the following formula. (Your score is x and your Grade-Point is p, using real arithmetic)

Then you can get the GPA with the following formula (the Grade-Point of course i is pi, and the credit of course i is wi).

Now it is not far from the final exam, if you do not review, you can only get a basic score in each course.

You have n days to review. There are K classes in each day. For each class, only one course can be reviewed. After the review, your score in this course will exactly increase by 1. You can get more increment by spending more classes in this course. But the score may not exceed 100.

For some reasons, not any course can be reviewed in any class. Each day you can only review some of the courses.

Now you want your GPA to be as high as possible, and at the same time, you do not want to fail in any course. Please calculate the highest GPA you can get. 
 

Input

The input consists of several test cases. Each test case begins with 3 integers N (0<=N<=40), K(0<K<=20), M (0<M<=20), representing the number of days, the number of classes in each day and the number of courses. Next line contains M integers representing credits of each course and M integers representing basic scores of each course (0<=score<=100). Next N lines contain an N*M matrix, the jth element in ith row means whether you can review course j in ith day, 1 means you can review course j in ith day, 0 means you cannot. The Input ends with 0 0 0.
 

Output

For each test case, output the highest possible GPA, round to 6 digits after decimal point. If you have to fail a course, output 0.000000 instead.
 

Sample Input

2 10 31 1 250 60 901 1 01 0 12 20 41 1 1 150 50 50 401 1 1 00 0 0 10 0 0

Sample Output

2.7578130.000000

Source

2012 ACM/ICPC Asia Regional Jinhua Online
 
解题:最小费用最大流,最大费用最大流
 

HDU 4406 GPA