AlgoUniversity
  • Go Back
Discussion
Minimum Health :

Author

Ayush Gangwani

Difficulty Level : Easy

Submissions : 198

Asked In : ZScaler

Marks :10

: 4 | : 0

You are given an array $$$A$$$ of $$$n$$$ integers. We will add $$$m$$$ elements one by one to the array $$$A$$$. You need to find the sum of $$$k^{th}$$$ largest element in the array $$$A$$$ initially and after each addition.

Input

The first line of input contains an integer $$$t$$$ $$$(1 \le t \le 10^4)$$$ — the number of testcases. The description of $$$t$$$ testcases follows.

The first line of each testcase contains three space separated integers $$$n, m (1 \le n,m \le 10^5)$$$ and $$$k$$$ $$$(1 \le k \le n)$$$ — the number of initial elements in array $$$A$$$, the number of elements to be added and the value of $$$k$$$ specified in the statement respectively.

The second line of each testcase contains $$$n$$$ space separated integers $$$a_1, a_2,... a_n$$$ — the initial elements of the array $$$A$$$.

The third line of each testcase contains $$$m$$$ space separated integers $$$b_1, b_2,... b_m$$$ — the elements to be added successively to array $$$A$$$.

Output

For each test case, print a single integer — the sum of $$$k^{th}$$$ largest element in the array $$$A$$$ initially and after adding the $$$m$$$ elements successively.

Example

Input
1
2 2 2
1 2
3 4
Output
6

Note

In the sample test case,

  • Initially, $$$A = [1, 2]$$$, so the $$$2^{nd}$$$ largest element is $$$1.$$$
  • After adding $$$3$$$, $$$A = [1,2,3]$$$, so the $$$2^{nd}$$$ largest element is $$$2.$$$
  • After adding $$$4$$$, $$$A = [1,2,3,4]$$$ so the $$$2^{nd}$$$ largest element is $$$3$$$.

Their sum is $$$1+2+3=6$$$, Hence we output $$$6.$$$

You need to login to view your submissions.

You need to login to view all submissions.

Loading...

Result : Executed

Loading...

Feel something is wrong with the test cases?

Result : Accepted

Test Cases :

You need to Log In
We're glad that you want to attempt this problem!

But to Run or Submit the Problem, you need to Log In.

Continue to Log In
Challenge Submitted!

Your challenge has been submitted successfully.

You will get a response soon via WhatsApp or Email.

Challenge
Facing issue while trying to solve the problem! Don't worry, we got you covered!

Do let us know your issue.

Looks good!
Please enter your issue / feedback.

How do we get in touch with you?
Looks good!
Please enter your phone no.
Looks good!
Please enter your email address.