1044.Boys and Girls
提交状态 耗时 内存 语言 提交时间

1044.Boys and Girls

时间限制:1000MS  内存限制:65535KB
题目描述
    The annual Children’s Day is coming.Teacher Chen with other teachers is considering rewarding the acmer of swust.Then what is the present?Surely,it is the lollipop!Assuming there are N boys,M girls.The ith boy will get Ai candies,the ith girl will get Bi candies if there is no restriction.But there keeps intimate relationship between some boys and some girls (You know it!),so they won’t be get candies simultaneously.the following example will explain it:
    Assuming there is a boy B and a girl G,if there is no restriction,Boy B will get x candies,Girl G will get y candies.But based on the intimate relationship between them , they can’s get candies simultaneously,so the most candies they get are Max(x,y).
    Now,Here comes the problem:choose some girls and boys to get the most candies for them,what’s more,it must guarantee that none any so-called intimate relationship exists among them.
    You,as a talented programmer,must have the ability to find the most candy numbers they get.Right?
输入描述
    The first line of input contains a number T, representing the numbers of test cases.Then each test case contains three parts:
    The first part: N and M(1<=N,M<=200),representing the numbers of boys and girls respectively.
    The second part: N numbers,representing the candy numbers, Ai(0<Ai<=100) for the ith boy under nonrestraint condition from left to right(1<=i<=N).
    The third part: M numbers,representing the candy numbers, Bi (0<Bi<=100) for the ith girl under nonrestraint condition from left to right(1<=i<=M).
    The last part: one 0-1 matrix with its size N by M.Considering the ith row,the jth column element of it.if 1,representing that the ith boy and the jth girl keep intimate relationship,so they can’s get candies simultaneously.otherwise 0,representing they can get candies simultaneously.
输出描述
Output the most candy numbers they can get.
示例
输入样例
1
2 2
3 4
3 5
0 1
0 0
输出样例
12
提示
相关标签
登陆后才可以提交
测试输入
执行结果
控制台
代码编辑器配置
  • 字体设置
    调整适合你的字体大小。
  • 主题设置
    切换不同的代码编辑器主题,选择适合你的语法高亮。
  • 行宽限制
    设置每一行代码的最大字符个数,设置为0则不限制。