Xiao Ming's mom is going on a m days' holiday, she prepares n red pockets for Xiao Ming (from No.1 to No.n). The NO.i red pocket have ai yuan.
Xiao Ming can open exactly one pocket per day.
During the time his mom is not at home, he can date with his girlfriend Xiao Hua. But to date with Xiao Hua, Xiao Ming has to spend bi yuan on the i-th day.
On each evening, he has to hand in the rest money of that day to his father (what a ruthless class exploitation!) (the rest money can be zero), so on the second day, he has to open a new red pocket.
But when his mom returns, the rest n-m red pockets can be remain, the money in these red pocket can be his forever. In order to save money to marry Xiao Hua, Xiao Ming wants to know how much money he can have at last as much as possible.
Input
There are multiple cases in the input file.
The first line of the input file contains a single integer T (1 ≤ T ≤ 10), representing the number of cases.
Then in each case, the first line contains two integers n and m (1 ≤ m ≤ n ≤ 100000)
The second line contains n integer, the i-th integer represents how much money is there in the i-th red packet.(0 ≤ money ≤ 108)
The third line contains m integers, the i-th integer represents how much money Xiao Ming needs in the i-th day.(0 ≤ money ≤ 108)
(There are not two pockets that have the same money.)
Output
If one day the money Xiao Ming need is more than that each red pocket he has, print "You Lost Xiao Hua~". Print the strings without quotes.
Otherwise for each test case output one integer that the money Xiao Ming have at last ( mod 108+3 ).
Sample Input
2 10 5 1 3 5 7 9 2 4 6 8 11 4 2 3 7 10 10 5 1 2 3 4 5 6 7 8 9 10 3 5 7 10 10
Sample Output
29 You Lost Xiao Hua~
题目大意:Mom要出去m天,留下m个红包,每个红包有mi;然后主人公和女票可以玩n天,每天花费ni;然后在这几天内,花剩下的得交上去充公, 剩下0块也允许, 但是不能负债; 问剩下的几天能留下多少钱自己花
题解:贪心, 快排后去对两个数组进行查询即可 , 只要满足刚好大或者差价尽可能小(因为充公少未来留下的越多)
AC代码:
#include <bits/stdc++.h>
using namespace std;
long long MOD = 100000003;
int a[100010], b[100010];
int main()
{
int t;
cin>>t;
while (t--)
{
int n, m;
cin>>m>>n;
for (int i = 0; i < m; i++) scanf("%d", &a[i]);
for (int i = 0; i < n; i++) scanf("%d", &b[i]);
sort(a, a + m);
sort(b, b + n);
long long sum = 0;
int j = 0 ;
for (int i = 0; i < m; i++)
{
if (j==n) sum += a[i];
else if (a[i] < b[j]) sum+=a[i] ;
else j++;
sum %= MOD;
}
if (j == n) printf("%lld\n", sum);
else printf("You Lost Xiao Hua~\n");
}
}