summer 1036 Red Pocket

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");

	}
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Kelisita

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值