CF670C.Cinema

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Moscow is hosting a major international conference, which is attended by nn scientists from different countries. Each of the scientists knows exactly one language. For convenience, we enumerate all languages of the world with integers from 11 to 10910^{9} .

In the evening after the conference, all nn scientists decided to go to the cinema. There are mm movies in the cinema they came to. Each of the movies is characterized by two distinct numbers — the index of audio language and the index of subtitles language. The scientist, who came to the movie, will be very pleased if he knows the audio language of the movie, will be almost satisfied if he knows the language of subtitles and will be not satisfied if he does not know neither one nor the other (note that the audio language and the subtitles language for each movie are always different).

Scientists decided to go together to the same movie. You have to help them choose the movie, such that the number of very pleased scientists is maximum possible. If there are several such movies, select among them one that will maximize the number of almost satisfied scientists.

输入格式

The first line of the input contains a positive integer nn ( 1<=n<=2000001<=n<=200000 ) — the number of scientists.

The second line contains nn positive integers a1,a2,...,ana_{1},a_{2},...,a_{n} ( 1<=ai<=1091<=a_{i}<=10^{9} ), where aia_{i} is the index of a language, which the ii -th scientist knows.

The third line contains a positive integer mm ( 1<=m<=2000001<=m<=200000 ) — the number of movies in the cinema.

The fourth line contains mm positive integers b1,b2,...,bmb_{1},b_{2},...,b_{m} ( 1<=bj<=1091<=b_{j}<=10^{9} ), where bjb_{j} is the index of the audio language of the jj -th movie.

The fifth line contains mm positive integers c1,c2,...,cmc_{1},c_{2},...,c_{m} ( 1<=cj<=1091<=c_{j}<=10^{9} ), where cjc_{j} is the index of subtitles language of the jj -th movie.

It is guaranteed that audio languages and subtitles language are different for each movie, that is bjcjb_{j}≠c_{j} .

输出格式

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 are several such movies, you need to choose among them one, after viewing which there will be the maximum possible number of almost satisfied scientists.

If there are several possible answers print any of them.

输入输出样例

  • 输入#1

    3
    2 3 2
    2
    3 2
    2 3
    

    输出#1

    2
    
  • 输入#2

    6
    6 3 1 1 3 7
    5
    1 2 3 4 5
    2 3 4 5 1
    

    输出#2

    1
    

说明/提示

In the first sample, scientists must go to the movie with the index 22 , as in such case the 11 -th and the 33 -rd scientists will be very pleased and the 22 -nd scientist will be almost satisfied.

In the second test case scientists can go either to the movie with the index 11 or the index 33 . After viewing any of these movies exactly two scientists will be very pleased and all the others will be not satisfied.

首页