当前位置:网站首页>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 代码
边栏推荐
- 第二十二章 源代码文件 REST API 参考(四)
- [Go WebSocket] 多房间的聊天室(一)思考篇
- 越折腾越好用的 3 款开源 APP
- LeetCode50天刷题计划(Day 18—— 搜索旋转排序数组(8.50-12.00)
- Some tips for using Unsafe
- The brave rice rice, does not fear the brush list of 】 list has a ring
- blocking non-blocking poll mechanism asynchronous
- 今天面了个腾讯拿38K出来的大佬,让我见识到了基础的天花板
- 接口定义与实现
- Alibaba最新神作!耗时182天肝出来1015页分布式全栈手册太香了
猜你喜欢

GPU accelerated Pinterest recommendation model, the number of parameters increased by 100 times, and the user activity increased by 16%

VSCode远程连接服务器报错:Could not establish connection to “xxxxxx”的可能错误原因及解决

中小规模网站架构

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

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

3款不同类型的自媒体免费工具,有效提高创作、运营效率

ISO9001在讲什么?过程方法和风险思维

【电商运营】你真的了解社交媒体营销(SMM)吗?

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

MLX90640 红外热成像仪测温传感器 手机 APP 软件 RedEye 连接详细
随机推荐
力扣练习——64 最长和谐子序列
[Go WebSocket] 多房间的聊天室(一)思考篇
老板加薪!看我做的WPF Loading!!!
Redis设计与实现
使用.NET简单实现一个Redis的高性能克隆版(六)
接口定义与实现
十年架构五年生活-09 五年之约如期而至
力扣练习—— 矩形区域不超过 K 的最大数值和(hard)
第2章-矩阵及其运算-矩阵运算(2)
基于UiAutomator2+PageObject模式开展APP自动化测试实战
AutoCAD Map 3D功能之一暴力处理悬挂点(延伸)
Some tips for using Unsafe
使用哈工大LTP测试分词并且增加自定义字典
What is an abstract class
YTU 2894: G--我要去内蒙古大草原
Centos7 environment uses Mysql offline installation package to install Mysql5.7
Weilai-software development engineer side record
Nocalhost - 让云原生时代的开发更高效
Centos7环境使用Mysql离线安装包安装Mysql5.7
关于振弦采集模块及采集仪振弦频率值准确率的问题