当前位置:网站首页>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 代码
边栏推荐
猜你喜欢
什么是幂等性?四种接口幂等性方案详解!
mysql出现:ERROR 1524 (HY000): Plugin ‘123‘ is not loaded
[E-commerce operation] Do you really understand social media marketing (SMM)?
AutoCAD Map 3D功能之一暴力处理悬挂点(延伸)
How to join We Media, learn about these 5 monetization modes, and make your account quickly monetize
微信小程序提交审核历史版本记录从哪里查看
【勇敢饭饭,不怕刷题之链表】链表倒数节点问题
VSCode远程连接服务器报错:Could not establish connection to “xxxxxx”的可能错误原因及解决
ENVI 5.3软件安装包和安装教程
StoneDB 文档捉虫活动第一季
随机推荐
Interviewer: How are Dao, Service, Controller, Util, and Model divided in the project?
基于UiAutomator2+PageObject模式开展APP自动化测试实战
Codeforces 862 C. Mahmoud and Ehab and the xor (技巧)
实现内网穿透的最佳解决方案(无实名认证,完全免费)
Licking Exercise - 63 Find all anagrams in a string
Unsafe的一些使用技巧
即时零售业态下如何实现自动做账?
做自媒体月入几万?博主们都在用的几个自媒体工具
【无标题】
老板加薪!看我做的WPF Loading!!!
力扣练习——64 最长和谐子序列
Double.doubleToLongBits() method uses
软件架构简介
使用哈工大LTP测试分词并且增加自定义字典
In August the DB list latest scores - database Engines
中小规模网站架构
程序员追求技术夯实基础学习路线建议
POJ 1026 Cipher (置换群)
力扣练习——61 根据字符出现频率排序
2023版揽胜运动曝光,安全、舒适一个不落