QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 32 MB Points totaux : 10

#10385. 递减序列 [B]

Statistiques

考虑一个整数序列 $a_{1}, a_{2}, \ldots, a_{n}$。一个(严格)递增的下标序列 $c_{1}, c_{2}, \ldots, c_{p}$(其中 $1 \le c_{i} \le n$)被称为下降序列,如果满足 $a_{c_{1}} > a_{c_{2}} > \ldots > a_{c_{p}}$。

如果对于某个 $k \in [1, p]$,满足对于所有 $i \in [1, k-1]$ 都有 $c_{i} = d_{i}$ 且 $c_{k} < d_{k}$,则称下标序列 $c_{1}, c_{2}, \ldots, c_{p}$ 在字典序上小于下标序列 $d_{1}, d_{2}, \ldots, d_{p}$。

你的任务是回答若干次查询:找出字典序第 $k$ 小的长度为 $p$ 的下降下标序列。

输入格式

输入的第一行包含三个整数 $n$、$p$ 和 $q$($1 \le n, q \le 100\,000$,$1 \le p \le 10$),分别表示序列 $a_{i}$ 的长度、所考虑的下降序列的长度以及查询次数。第二行包含 $n$ 个整数 $a_{i}$($-10^{9} \le a_{i} \le 10^{9}$)。接下来的 $q$ 行包含查询描述:第 $j$ 行包含一个整数 $k_{j}$($1 \le k_{j} \le 10^{18}$)。

输出格式

你的程序应向标准输出写入 $q$ 行。第 $j$ 行应包含第 $k_{j}$ 小的下降下标序列,如果不存在该序列,则输出 -1。

样例

输入 1

5 3 3
-1 6 5 2 1
1
5
3

输出 1

2 3 4 
-1
2 4 5

说明

在本例中,长度为 3 的下降下标序列按字典序排列如下:(2, 3, 4), (2, 3, 5), (2, 4, 5) 和 (3, 4, 5)。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.