当前位置:网站首页>HDU 6040 Hints of sd0061 (技巧)
HDU 6040 Hints of sd0061 (技巧)
2022-08-10 11:04:00 【51CTO】
Description
sd0061, the legend of Beihang University ACM-ICPC Team, retired last year leaving a group of noobs. Noobs have no idea how to deal with m coming contests. sd0061 has left a set of hints for them.
There are n noobs in the team, the i-th of which has a rating ai. sd0061 prepares one hint for each contest. The hint for the j-th contest is a number bj, which means that the noob with the (bj+1)-th lowest rating is ordained by sd0061 for the j-th contest.
The coach asks constroy to make a list of contestants. constroy looks into these hints and finds out: bi+bj≤bk is satisfied if bi≠bj, bi
Input
There are multiple test cases (about 10).
For each test case:
The first line contains five integers n,m,A,B,C. (1≤n≤10^7,1≤m≤100)
The second line contains m integers, the i-th of which is the number bi of the i-th hint. (0≤bi
Output
For each test case, output “Case #x: y1 y2 ⋯ ym” in one line (without quotes), where x indicates the case number starting from 1 and yi (1≤i≤m) denotes the rating of noob for the i-th contest of corresponding case.
Sample Input
Sample Output
题意
用题中所给的函数生成 n 个数,然后有 m 次查询,查询数列 a 中第 bi
思路
如果单纯想着排序以后直接输出的话会超时,因为 n 最大有 107
那么就应该想想其他线性的解法了, STL 库中实现了 nth_element 函数,其功能是使第 n 大元素处于第 n 个位置,并且比这个元素小的元素都排在它之前,比这个元素大的元素都排在它之后,但不能保证它们是有序的。
时间复杂度:平均为线性。
然后在使用过程中做一点点的优化就可以了,题中有说 bi+bj≤bk
AC 代码
边栏推荐
- 【勇敢饭饭,不怕刷题之链表】链表倒数节点问题
- 实现内网穿透的最佳解决方案(无实名认证,完全免费)
- 关于“码农”的一点自嘲解构
- 微信小程序提交审核历史版本记录从哪里查看
- 面试官:项目中 Dao、Service、Controller、Util、Model 怎么划分的?
- Buckle exercise - rectangular area does not exceed the maximum value of K and (hard)
- 3款不同类型的自媒体免费工具,有效提高创作、运营效率
- 不止跑路,拯救误操作rm -rf /*的小伙儿
- 力扣练习——62 有效的数独
- POJ 2891 Strange Way to Express Integers (Extended Euclidean)
猜你喜欢

mysql appears: ERROR 1524 (HY000): Plugin '123' is not loaded

Alibaba最新神作!耗时182天肝出来1015页分布式全栈手册太香了

Memory problems difficult to locate, it is because you do not use ASAN

自媒体爆款标题怎么写?手把手教你写热门标题

电脑怎么设置屏幕息屏时间(日常使用分享)
![[Brave food, not afraid to write the linked list] The problem of the penultimate node of the linked list](/img/87/7ac0307de54f2defe8f72c554745cd.png)
[Brave food, not afraid to write the linked list] The problem of the penultimate node of the linked list

基于UiAutomator2+PageObject模式开展APP自动化测试实战

StoneDB Document Bug Hunting Season 1
![[Brave food, not afraid of the linked list of brushing questions] Merging of ordered linked lists](/img/06/9d49fc99ab684f03740deb2abc38e2.png)
[Brave food, not afraid of the linked list of brushing questions] Merging of ordered linked lists

The impact of development mode on testing
随机推荐
力扣练习——64 最长和谐子序列
Spss-多元回归案例实操
第3章-线性方程组(3)
std::move()
C#实战:基于ItextSharp技术标签生成小工具
The brave rice rice, does not fear the brush list of 】 list has a ring
即时零售业态下如何实现自动做账?
推荐6个自媒体领域,轻松易上手
Gartner reiterates the important value of 'data weaving'
Mount [shell][mount -o loop]
Buckle exercise - rectangular area does not exceed the maximum value of K and (hard)
LeetCode50天刷题计划(Day 19—— 在排序数组中查找元素的第一个和最后一个位置(9.10-10.40)
The impact of development mode on testing
【勇敢饭饭,不怕刷题之链表】有序链表的合并
2023版揽胜运动曝光,安全、舒适一个不落
为什么Redis很快
第二十二章 源代码文件 REST API 参考(四)
Clicking Exercise - 64 Longest Harmonic Subsequences
单目操作符(含原码反码补码转换)
老板加薪!看我做的WPF Loading!!!