AT_scpc2026_div2_f.The Kth Smallest Number

入门

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

An infinite sequence (an)(a_n) satisfies the following property.

  • For every positive integer ii satisfying i>Ni>N, aia_i is equal to the KK-th element of ai−N,ai−N+1,…,ai−1a_{i-N},a_{i-N+1},\dots,a_{i-1} after these values are sorted in nondecreasing order.

Once the values of a1,…,aNa_1,\dots,a_N are determined, the values of aN+1,aN+2,…a_{N+1},a_{N+2},\dots are uniquely determined.

You are given the values of NN, KK, MM and a1,…,aNa_1,\dots,a_N. Find aMa_M.

一个无限序列 (an)(a_n) 满足如下性质:

  • 对每个满足 i>Ni>N 的正整数 ii,aia_i 等于将 ai−N,ai−N+1,…,ai−1a_{i-N},a_{i-N+1},\dots,a_{i-1} 按非递减顺序排序后所得序列中的第 KK 个元素。

一旦确定了 a1,…,aNa_1,\dots,a_N 的值,则 aN+1,aN+2,…a_{N+1},a_{N+2},\dots 的值被唯一确定。

给定 NN、KK、MM 以及 a1,…,aNa_1,\dots,a_N 的值,求 aMa_M。

输入格式

The input is given from Standard Input in the following format:

NN KK MM
a1a_1 a2a_2 …\dots aNa_N

输入从标准输入中按以下格式给出:

NN KK MM
a1a_1 a2a_2 …\dots aNa_N

输出格式

Output the answer.

输出答案。

输入输出样例

  • 输入#1

    8 6 9
    2 0 2 6 0 5 1 6

    输出#1

    5
  • 输入#2

    1 1 1
    1

    输出#2

    1

说明/提示

表示言語

/ /

Sample 1 Explanation:
Sorting [2,0,2,6,0,5,1,6][2,0,2,6,0,5,1,6] in nondecreasing order, we have [0,0,1,2,2,5,6,6][0,0,1,2,2,5,6,6]. Since K=6K=6, we have a9=5a_9=5.

Sample 2 Explanation:


Constraints

  • 1≤K≤N≤300 0001 \leq K \leq N \leq 300\,000
  • 1≤M≤10181 \leq M \leq 10^{18}
  • −109≤ai≤109-10^9 \leq a_i \leq 10^9
  • All input values are integers.

表示语言

/ /

样例 1 解释:
将 [2,0,2,6,0,5,1,6][2,0,2,6,0,5,1,6] 按非递减顺序排序,得到 [0,0,1,2,2,5,6,6][0,0,1,2,2,5,6,6]。由于 K=6K=6,故 a9=5a_9=5。

样例 2 解释:


约束条件

  • 1≤K≤N≤300 0001 \leq K \leq N \leq 300\,000
  • 1≤M≤10181 \leq M \leq 10^{18}
  • −109≤ai≤109-10^9 \leq a_i \leq 10^9
  • 所有输入值均为整数。

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

首页