当前位置:网站首页>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 代码
边栏推荐
猜你喜欢
![[E-commerce operation] Do you really understand social media marketing (SMM)?](/img/5b/6682c613305deb3dc15401077d38a0.png)
[E-commerce operation] Do you really understand social media marketing (SMM)?

振弦传感器及核心VM系列振弦采集模块

单目操作符(含原码反码补码转换)

【电商运营】你真的了解社交媒体营销(SMM)吗?
![[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

A little self-deprecating deconstruction about farmers "code"

机器学习之暴力调参案例

Redis设计与实现

mysql出现:ERROR 1524 (HY000): Plugin ‘123‘ is not loaded

如何使用工程仪器设备在线监测管理系统
随机推荐
The impact of development mode on testing
POJ 3101 Astronomy (数学)
做自媒体月入几万?博主们都在用的几个自媒体工具
使用JMeter进行MySQL的压力测试
一文带你搞懂中断按键驱动程序之poll机制
力扣练习——59 从二叉搜索树到更大和树
LeetCode50天刷题计划(Day 18—— 搜索旋转排序数组(8.50-12.00)
Do self-media monthly income tens of thousands?Several self-media tools that bloggers are using
AUTOCAD——减少样条曲线控制点数、CAD进阶练习(三)
第2章-矩阵及其运算-矩阵创建(1)
CodeChef STMRRG String Merging (dp)
【机器学习】浅谈正规方程法&梯度下降
Buckle Exercise - 61 Sort by frequency of characters
Pycharm终端出现PS问题、conda或activate不是内部命令问题..
Licking Exercise - 63 Find all anagrams in a string
【勇敢饭饭,不怕刷题之链表】有序链表的合并
第二十二章 源代码文件 REST API 参考(四)
POJ 2891 Strange Way to Express Integers (扩展欧几里得)
Since the media hot style title how to write?Taught you how to write the title
基于UiAutomator2+PageObject模式开展APP自动化测试实战