当前位置:网站首页>ZCMU--1771: 寻找萌妹
ZCMU--1771: 寻找萌妹
2022-07-15 12:55:00 【小小小Why】
Description
某个同学又有很多小姊妹了,他喜欢聪明的小姊妹 所以经常用神奇的函数来估算小姊妹的智商
他得出了自己所有小姊妹的智商,小姊妹的智商都是非负整数,但是这个同学看到别的同学的小姊妹
也喜欢用神奇的函数估算一下,然后看看这个小姊妹在自己的小姊妹群体中排在第几位...
Input
第一行一个整数N 代表小姊妹的个数
第二行N个整数 代表这位同学N个小姊妹的智商
接下来若干行 每行一个整数
代表这位同学看中的别人的小姊妹的智商
0<=智商<=2^31-1
0<=N<=1000000
Output
输出若干行
每行一个整数 回答新的小姊妹
在原来小姊妹中智商的排名
Sample Input
5
1 2 3 4 5
1
2
3
4
5
Sample Output
1
2
3
4
5
解析:原始智商组升序排序,然后输入L,返回第一个大于等于L的位置即可,关于输入若干行,用while(~scanf("%d",&l))输入即可。
#include <stdio.h>
#include <algorithm>
using namespace std;
int a[1000005];
int main()
{
int n,i,l,z,mid,y;
scanf("%d",&n);
for(i=0;i<n;i++) scanf("%d",&a[i]);
sort(a,a+n); //升序排序
while(~scanf("%d",&l)){
z=0,y=n-1;
while(z<y){
mid=(z+y)/2;
if(a[mid]>=l) y=mid;
else z=mid+1;
}
if(l>a[n-1]) printf("%d\n",n+1);//特判比最大的还大,排名就是n+1
else printf("%d\n",y+1);
}
return 0;
}边栏推荐
- ArkUI常见问题汇总【系列1】
- [Voforia] 通过识自己设定图片,显示特定AR模型
- PD server grpc interface diagram
- 软考 系统架构设计师 简明教程 | 政府信息化与电子政务
- Implementation of ZABBIX proxy active mode
- The four functions of MES management system can effectively improve the digitalization of the factory
- Change buffer introduction
- MES管理系统的四个功能,高效提升工厂数字化
- Tencent T4 architects give you a "glimpse" of the main technical challenges and solutions of large website architecture
- 网络基础学习系列二(socket编程)
猜你喜欢

torch.nn.CTCLoss()的使用

Really cow b! JD t3-2 is still learning microservice +mysql+kafka+boot2 X+ virtual machine pdf

Implementation of ZABBIX proxy active mode

世界首款抗量子攻击商用密码芯片 | 沐创

Zabbix proxy主動模式的實現

Tikv & tiflash accelerates complex business queries

抢占新赛道,和数集团大力布局“元宇宙”产业

在我旁边的同事突然晋升美团P7,却是只因偷偷学习了这份JVM笔记?

std::unique_ The use of PTR as a formal parameter

让企业数字化砸锅和IT主管背锅的软件供应链安全风险指北
随机推荐
Bufferedinputstream byte cache input stream and cache stream efficiency test_ Copy files
Google Earth engine (GEE) - random forest classification has mapped the detailed code of mangrove app in Guyana in 2000, 2010 and 2020
你了解MySQL的架构与引擎吗?
[Vuforia] 详解·高通Vuforia识别追踪3D物体/模型,Unity开发
Change buffer introduction
C# 使用ToolTip控件实现气泡提示
四面阿里offer定级P8,2022最新最实用阿里68道高级面试题,助你们面试成功!!
Implementation of ZABBIX proxy active mode
Flutter中的IndexedStack
Can all three nodes of polardb for PostgreSQL read and write?
曾经,我对着AI客服喷了两分钟,它只回复了我的第一句话
Andorid studio makes happy writing numbers (timer start + frame animation)
腾讯T4架构师带你“一窥”大型网站架构的主要技术挑战和解决方案
The world's first commercial cryptographic chip against quantum attack | Muchuang
Codeforces round 804 (Div. 2) d. almost triple deletions time limit per test2 seconds (DP good questions)
OpenHarmony藏头诗应用
Redis连接池
Really cow b! JD t3-2 is still learning microservice +mysql+kafka+boot2 X+ virtual machine pdf
Layout meta universe social networking, and the digital economy will usher in new opportunities for development
How does Xishanju build a game industry assembly line with ones? | Ones industry practice