Romeo and JulietProblem code: TOGETHER |
All submissions for this problem are available.
|
|
Romeo and Juliet are in a long distance relationship. They both are working in software industry. As a result, both of them are busy coding most of the days. There are in total N days ( numbered 1, 2, 3, ... , N ) and each day can be a working day for either Juliet or Romeo or both. |
Juliet is very brave and wants to skip exactly K continuous days to go and meet Romeo. But she wants to select these K days ( from the N days ) in such a way that she can spend maximum number of days with Romeo. If there are multiple ways to select these days, she wants to select the one in which she misses minimum number of her working days. Still if there are multiple ways, she selects the one in which she can meet Romeo as early as possible.
Given the working days of Romeo and Juliet, help Juliet select K days in which she can visit Romeo. Output the starting day number of Juliet's visit to meet Romeo.
Note: Romeo can't take a leave on a working day and hence can't spend that day with Juliet.
Input
First line contains T , the number of test cases. Each test case has 3 lines. First line contains N and K. Second line begins with an integer R, the number of working days for Romeo. This is followed by R integers in the same line, the working days of Romeo. Third line begins with an integer J, the number of working days for Juliet. This is followed by J integers in the same line, the working days of Juliet.
T <= 10
1 <= N <=100000
1 <= K <= N
0 <= R <=N
0 <= J <=N
Output
Output the starting day number of Juliet's visit to meet Romeo.
Example
Input: 4 6 3 3 1 3 5 2 2 3 6 3 3 1 3 5 1 3 1 1 1 1 1 1 6 3 2 2 5 2 1 4 Output: 4 4 1 1
| Author: | rosyish |
| Date Added: | 22-02-2011 |
| Time Limit: | 1 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC |
Comments
SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:
HELP
Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:
- Accepted
Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark. - Time Limit Exceeded
Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach. - Wrong Answer
Your program compiled and ran succesfully but the output did not match the expected output. - Runtime Error
Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section. - Compilation Error
Your code was unable to compile. When you see this icon, click on it for more information.
If you are still having problems, see a sample solution here.


Fetching successful submissions
