CF1181D.Irrigation

提高+/省选-

通过率:0%

时间限制:2.50s

内存限制:512MB

AC君温馨提醒

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

题目描述

Misha was interested in water delivery from childhood. That's why his mother sent him to the annual Innovative Olympiad in Irrigation (IOI). Pupils from all Berland compete there demonstrating their skills in watering. It is extremely expensive to host such an olympiad, so after the first nn olympiads the organizers introduced the following rule of the host city selection.

The host cities of the olympiads are selected in the following way. There are mm cities in Berland wishing to host the olympiad, they are numbered from 11 to mm. The host city of each next olympiad is determined as the city that hosted the olympiad the smallest number of times before. If there are several such cities, the city with the smallest index is selected among them.

Misha's mother is interested where the olympiad will be held in some specific years. The only information she knows is the above selection rule and the host cities of the first nn olympiads. Help her and if you succeed, she will ask Misha to avoid flooding your house.

米沙从小就对供水问题很感兴趣,因此他母亲送他参加了年度创新灌溉奥林匹克竞赛(IOI)。来自贝尔兰各地的学生都会参赛,展示各自的灌溉技能。举办这样的奥林匹克竞赛费用极其高昂,因此在前 nn 届竞赛之后,主办方引入了如下主办城市选择规则。

奥林匹克竞赛的主办城市按以下方式选定:贝尔兰共有 mm 个希望主办该赛事的城市,编号从 11 到 mm。下一届奥林匹克竞赛的主办城市,是此前主办次数最少的城市。若存在多个满足条件的城市,则从中选出编号最小的那个。

米沙的母亲想知道某些特定年份的奥林匹克竞赛将在哪里举行。她所掌握的唯一信息就是上述选择规则以及前 nn 届奥林匹克竞赛的主办城市。请帮助她解决这个问题;如果你成功了,她会让米沙避免把你家淹掉。

输入格式

The first line contains three integers nn, mm and qq (1≤n,m,q≤500 0001 \leq n, m, q \leq 500\,000) — the number of olympiads before the rule was introduced, the number of cities in Berland wishing to host the olympiad, and the number of years Misha's mother is interested in, respectively.

The next line contains nn integers a1,a2,…,ana_1, a_2, \ldots, a_n (1≤ai≤m1 \leq a_i \leq m), where aia_i denotes the city which hosted the olympiad in the ii-th year. Note that before the rule was introduced the host city was chosen arbitrarily.

Each of the next qq lines contains an integer kik_i (n+1≤ki≤1018n + 1 \leq k_i \leq 10^{18}) — the year number Misha's mother is interested in host city in.

第一行包含三个整数 nn、mm 和 qq(1≤n,m,q≤500 0001 \leq n, m, q \leq 500\,000),分别表示规则引入前已举办的奥林匹克竞赛次数、贝兰国希望承办奥林匹克竞赛的城市数量,以及米沙母亲所关心的年份数量。

第二行包含 nn 个整数 a1,a2,…,ana_1, a_2, \ldots, a_n(1≤ai≤m1 \leq a_i \leq m),其中 aia_i 表示第 ii 年举办奥林匹克竞赛的城市。注意,在规则引入之前,主办城市是任意选定的。

接下来的 qq 行中,每行包含一个整数 kik_i(n+1≤ki≤1018n + 1 \leq k_i \leq 10^{18}),表示米沙母亲所关心的第 kik_i 年的主办城市。

输出格式

Print qq integers. The ii-th of them should be the city the olympiad will be hosted in the year kik_i.

输出 qq 个整数。其中第 ii 个整数应为奥林匹克竞赛在年份 kik_i 举办的所在城市。

输入输出样例

  • 输入#1

    6 4 10
    3 1 1 1 2 2
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16

    输出#1

    4
    3
    4
    2
    3
    4
    1
    2
    3
    4
  • 输入#2

    4 5 4
    4 4 5 1
    15
    9
    13
    6

    输出#2

    5
    3
    3
    3

说明/提示

In the first example Misha's mother is interested in the first 1010 years after the rule was introduced. The host cities these years are 4, 3, 4, 2, 3, 4, 1, 2, 3, 4.

In the second example the host cities after the new city is introduced are 2, 3, 1, 2, 3, 5, 1, 2, 3, 4, 5, 1.

在第一个例子中,米沙的母亲关注的是该规则实施后的前 1010 年。这些年份的主办城市依次为 4、3、4、2、3、4、1、2、3、4。

在第二个例子中,新城市引入后的主办城市依次为 2、3、1、2、3、5、1、2、3、4、5、1。

输入解题思路,AI测评打分。不知道怎么写?

首页