翻译---

OpenJudge - 2104:K-th Number

2104:K-th Number

描述

You are working for Macrohard company in data structures department. After failing your previous task about key insertion you were asked to write a new data structure that would be able to return quickly k-th order statistics in the array segment.
That is, given an array a[1...n] of different integer numbers, your program must answer a series of questions Q(i, j, k) in the form: "What would be the k-th number in a[i...j] segment, if this segment was sorted?"
For example, consider the array a = (1, 5, 2, 6, 3, 7, 4). Let the question be Q(2, 5, 3). The segment a[2...5] is (5, 2, 6, 3). If we sort this segment, we get (2, 3, 5, 6), the third number is 5, and therefore the answer to the question is 5.

输入

The first line of the input file contains n --- the size of the array, and m --- the number of questions to answer (1 <= n <= 100 000, 1 <= m <= 5 000).
The second line contains n different integer numbers not exceeding 109 by their absolute values --- the array for which the answers should be given.
The following m lines contain question descriptions, each description consists of three numbers: i, j, and k (1 <= i <= j <= n, 1 <= k <= j - i + 1) and represents the question Q(i, j, k).

输出

For each question output the answer to it --- the k-th number in sorted a[i...j] segment.

第k个数字
描述:
你为了Macrohard公司的数据结构部门工作。在对关键插入的重要任务中失败了后,你被要求写一个新的数据结构,让它可以快速返回一个数据段中第k大的数。
那个意思是,给你一个有不同整数的数组a[1...n],你的程序必须用这样的形式回答许多问题Q(i, j, k):“什么是a[i...j]这个部分中第k大的数,如果这部分被排序了?”
例如,考虑这个数组a = (1, 5, 2, 6, 3, 7, 4)。我们让这个问题变成Q(2, 5, 3)。这个部分a[2...5] 是 (5, 2, 6, 3)。如果我们对这部分排序,我们得到了(2, 3, 5, 6),第三大的数是5,并且因此这个问题的回答是5.
输入:
第一行输入包括n——这个数组的大小,和m——回答问题的数目(1 <= n <= 100 000, 1 <= m <= 5 000)。
第二行包括n个绝对值不超过10的9次方的不同整数——应该被给出答案的数组。
接下来m行包括问题描述,每个描述包括三个数字:i,j和k(1 <= i <= j <= n, 1 <= k <= j - i + 1)并且代表问题Q(i, j, k)。
输出:
对于每个问题输出他的答案——在a[i...j]这部分第k大的数。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在这个例子中,我们需要使用Visual Studio Express来开始项目,并且需要取消掉代码中的一行,因为它会导致编译错误。使用Visual Studio Express的人必须在编译之前取消掉这行代码。\[1\] 关于英文翻译的比喻,可以想象你正在学习一门新的语言,比如法语。当你学习法语时,你可能不会记住每一个单词和短语,除非你多次重复学习。但是,当你去法国度假时,你会发现自己需要用法语与人交流。在这种情况下,你可以使用法语-英语字典来帮助你理解不熟悉的句子。类似地,当我们学习C++时,我们可能需要使用C++-英语翻译来帮助我们理解代码的含义。然而,最终我们希望能够流利地使用C++,就像我们希望能够流利地说法语一样。\[1\] 在这个问题中,引用\[2\]提供了输入的格式说明,第一行是两个正整数N和K,第二行是N个正整数。\[2\]引用\[3\]进一步解释了问题的背景,有N个袋子,每个袋子里有一些糖果。你可以拿走一些袋子,但是袋子里的糖果总数必须是K的倍数,因为你想要平均分给K个朋友。你最多可以拿走多少糖果?\[3\] #### 引用[.reference_title] - *1* [C++英文翻译。](https://blog.csdn.net/u013820713/article/details/20729393)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [英文翻译26](https://blog.csdn.net/fsy_and_zxc/article/details/122940794)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值