codeforces-670cCinema
| Time Limit: 2000MS |
|
Memory Limit: 262144KB |
|
64bit IO Format: %i64d &%i64u |
Submit Status
Description
Moscow is hosting a major international conference, which are attended by n Scien Tists from different countries. Each of the scientists knows exactly one language. For convenience, we enumerate all languages of the world with integers from1 to 109 .
In the evening after the conference, all N scientists decided to go to the Cinem A. There are m movies in the cinema they came to. Each of the movies are characterized by Twodistinct numbers -the Index of Audi o Language and the index of subtitles language. The scientist, who came to the movie, would bevery pleased if he knows the audio LAN Guage of the movie, would bealmost satisfied if he knows the language of subtitles a nd would benot satisfied if he does not know neither one or the other (note that th E Audio language and the subtitles language for each movie is always different).
Scientists decided to go together to the same movie. them choose the movie, such that number of very pleased scientists are maximum possible. If There is several such movies, select among them one that would maximize the number of almost satisfied scientists.
Input
The first line of the input contains a positive integer n (1?≤? N? ≤?200?000)-the number of scientists.
The second line contains n positive integersa1,? A2,?...,? An (1?≤? ) Ai? ≤?109), where ai is the index of a Language, which theI-th scientist knows.
The third line contains a positive integer m (1?≤? M≤?200?000)-the number of movies in the cinema.
The fourth line contains m positive integers b 1,? b 2,?...,? b m (1?≤? b J ? ≤?109 ), where b J is the index of the audio language of The J -th movie.
The fifth line contains m positive integersc1,? C2,?...,? Cm (1?≤? CJ. ≤?109), where cJ is the index of Subtitles language of theJ-th Movie.
It is guaranteed that audio languages and subtitles language be different for each movie, which isb j? ≠? C J .
Output
Print the single integer-the index of a movie to which scientists should go. After viewing this movie, the number of very pleased scientists should be maximum possible. If in the cinema there is several such movies, you need to choose among them one, after viewing which there would be the M Aximum possible number of almost satisfied scientists.
If there is several possible answers print any of them.
Sample Input
Input
32 3 223) 22 3
Output
2
Input
66 3 1 1 3 751 2 3 4 52 3 4 5 1
Output
1
Sample Output
Hint
Source
Codeforces Round #350 (Div. 2)//test instructions: There are n foreign friends who come to China to watch a movie, each of them will only be one language (different numbering table different language), now has M movie, each movie's voice is A[i], subtitle is b[i]. If the sound of the film he understood, he would be very satisfied, if the letter he can understand the words he will be more satisfied, otherwise it is not satisfied. Now ask which film will make n foreign friends the highest (if two movies make n foreign friends very satisfied with the number of the same, choose the most satisfied with the film). Idea: Because A[i],b[i] is very large, so you have to use map to save, and then the counting simulation to find the best solution on the line.
codeforces-670c Cinema (map& simulation) water