4500: A. Ban or Pick, What's the Trick
内存限制:1024 MB
时间限制:4 S
标准输入输出
题目类型:传统
评测方式:Special Judge
上传者:
提交:3
通过:0
题目描述
Bobo has recently learned how to play Dota2. In Dota2 competitions, the mechanism of banning/picking heroes is introduced, modified and simplified as follows for the sake of the problem:
Suppose a game is played between two teams: Team A and Team B. Each team has a hero pool of n heroes with positive utility scores a1,...,an and b1,...,bn, respectively. Here we assume all heroes in two teams' hero pool are distinct.The two teams then perform ban/pick operations alternately, with Team A going first. In one team's turn, it can either pick a hero for itself, or ban an unselected hero from the opponent's hero pool.
After 2n turns, all heroes are either picked or banned. Each team then needs to choose at most k heroes from all heroes it picked to form a warband and the score for the warband is calculated as the sum of utility scores over all heroes in it.
Let sA, sB be the score of the warband formed by Team A and Team B, respectively. Team A wants to maximize the value of sA-sB while Team B wants to minimize it.
Bobo wants to know, what should be the final value of sA-sB, if both teams act optimally? He's not really good at calculating this, so he turned to you for help.
Suppose a game is played between two teams: Team A and Team B. Each team has a hero pool of n heroes with positive utility scores a1,...,an and b1,...,bn, respectively. Here we assume all heroes in two teams' hero pool are distinct.The two teams then perform ban/pick operations alternately, with Team A going first. In one team's turn, it can either pick a hero for itself, or ban an unselected hero from the opponent's hero pool.
After 2n turns, all heroes are either picked or banned. Each team then needs to choose at most k heroes from all heroes it picked to form a warband and the score for the warband is calculated as the sum of utility scores over all heroes in it.
Let sA, sB be the score of the warband formed by Team A and Team B, respectively. Team A wants to maximize the value of sA-sB while Team B wants to minimize it.
Bobo wants to know, what should be the final value of sA-sB, if both teams act optimally? He's not really good at calculating this, so he turned to you for help.
An example of banning/picking heroes in Dota2. Source: TI10 True Sight
输入格式
The first line contains two integers n,k(1<= n<= 105,1<= k <= 10).
The second line contains n integers a1,a2,...,an (1<= ai<= 108), denoting the utility score of heroes for Team A.
The third line contains n integers b1,b2,...,bn (1<= bi<= 108), denoting the utility score of heroes for Team B.
The second line contains n integers a1,a2,...,an (1<= ai<= 108), denoting the utility score of heroes for Team A.
The third line contains n integers b1,b2,...,bn (1<= bi<= 108), denoting the utility score of heroes for Team B.
输出格式
Output an integer in one line, denoting the answer.
输入样例 复制
2 1
3 6
2 4
输出样例 复制
2
数据范围与提示
input
4 1 1 3 5 7 2 4 6 8output
0input
4 2 4 6 7 9 2 5 8 10output
3