CF69E.Subsegments
普及+/提高
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Programmer Sasha has recently begun to study data structures. His coach Stas told him to solve the problem of finding a minimum on the segment of the array in
, which Sasha coped with. For Sasha not to think that he had learned all, Stas gave him a new task. For each segment of the fixed length Sasha must find the maximum element of those that occur on the given segment exactly once. Help Sasha solve this problem.
程序员萨沙最近开始学习数据结构。他的教练斯塔斯让他解决一个在数组区间上求最小值的问题(见图:
),萨沙成功解决了该问题。为了不让萨沙以为自己已经学完了全部内容,斯塔斯又交给他一个新任务:对于每个固定长度的区间,他需要找出该区间内恰好出现一次的所有元素中的最大值。请帮助萨沙解决这个问题。
输入格式
The first line contains two positive integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ n) — the number of array elements and the length of the segment.
Then follow n lines: the i-th one contains a single number a__i ( - 109 ≤ a__i ≤ 109).
第一行包含两个正整数 n 和 k(1 ≤ n ≤ 105,1 ≤ k ≤ n)—— 分别表示数组元素个数和区间的长度。
接下来是 n 行:第 i 行包含一个数 ai(−109 ≤ ai ≤ 109)。
输出格式
Print n–k + 1 numbers, one per line: on the i-th line print of the maximum number of those numbers from the subarray a__i a__i + 1 … a__i + k - 1 that occur in this subarray exactly 1 time. If there are no such numbers in this subarray, print "Nothing".
输出 n−k+1 个数,每行一个:第 i 行输出子数组 ai,ai+1,…,ai+k−1 中恰好出现 1 次的那些数里的最大值;若该子数组中不存在这样的数,则输出 "Nothing"。
输入输出样例
输入#1
5 3 1 2 2 3 3
输出#1
1 3 2
输入#2
6 4 3 3 3 4 4 2
输出#2
4 Nothing 3
输入解题思路,AI测评打分。不知道怎么写?