Problem 3809 --Unfair contest

3809: Unfair contest

"
Time Limit $1$ 秒/Second(s) Memory Limit $128$ 兆字节/Megabyte(s)
提交总数 $0$ 正确数量 $0$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签
I'm going to give my scores fairly. It's just that some contestant deserves a fairer score... 

gispzjz and zyb are participating in a contest, with n referees awarding scores(according to their performance, usually) to them. For each contestant, each referee should name an integer in the interval [1,h] as the score, and the final score of the contestant is the sum over all scores he gets after eliminating s highest scores and tlowest scores.

As one of the referees, you had a bet on gispzjz, so you want him to win this contest, but you also don't want this to look too obvious. Suppose you know the other n−1 referees have awarded scores a1,…,an−1 to gispzjz and b1,…,bn−1 to zyb. You need to give out your scores an and bn so that the final score of gispzjz is strictly higher than zyb. If that's achievable, you also need to minimize an−bn, conditioned on the final score of gispzjz is strictly higher than zyb.
The first line contains a number T(1≤T≤12000), denoting the number of test cases.

The first line of each test case contains four integers n,s,t,h(1≤n≤105,0≤s,t≤n−1,1≤h≤109), denoting the number of referees, the number of highest and lowest scores that need to be eliminated, and the scoring range for referees, respectively. It is guaranteed that s+t≤n−1.

Then one line containing n−1 integers a1,...,an−1(1≤ai≤h) follow, denoting the scores already awarded to gispzjz. 

Then another line containing n−1 integers b1,...,bn−1(1≤bi≤h) follow, denoting the scores already awarded to zyb. 

It is guaranteed that n≤106 over all test cases.
For each test case, if it's possible to make gispzjz's score strictly higher than zyb, then output the minimized an−bn in one line, otherwise output "IMPOSSIBLE"(without quotes) in one line.
3
3 1 1 4
1 3
2 4
4 1 1 9
4 4 5
4 5 5
4 1 1 9
4 5 5
4 4 5
1
IMPOSSIBLE
-4

推荐代码 查看3809 所有题解 上传题解视频得图灵币

本题记录 用 户(点击查看用户) 运行号(点击购买题解) 时 间
算法最快[$ $ms]
内存最少[$ $KB]
第一AC
第一挑战

赛题来源/所属竞赛 N/A

竞赛编号 竞赛名称 竞赛时间 访问比赛