Problems
Contests
Events
Topic
IDE
PacketHub
Login
Description
Editorial
My Submission
1044.Boys and Girls
Look up all submission
Status
Time
Memory
Lang.
Submit Date
1044.Boys and Girls
Time Limit:1000MS Memory Limit:65535KB
Description
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?
Input
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, A~i~(0\
Output
Output the most candy numbers they can get.
Sample test
Sample input
1 2 2 3 4 3 5 0 1 0 0
Sample output
12
Note
Tags
bfs
Post editorial
Editorials
GNU C++ 9.3.0
GNU C 9.3.0
Java 1.8
Python 3.8.4
Lua 5.3
GO 1.12.4
JS - (nodejs 10.19.0)
Login before submit
Test Input
Test Output
1 2 2 3 4 3 5 0 1 0 0
Please run you code firstly.
Console
IDE Setting
字体设置
调整适合你的字体大小。
12px
13px
14px
15px
16px
18px
20px
主题设置
切换不同的代码编辑器主题,选择适合你的语法高亮。
Visual Studio
Visual Studio Dark
High Contrast Dark
行宽限制
设置每一行代码的最大字符个数,设置为0则不限制。
0
80
100
120