BUPT复试专题—排序(2009)
2024-09-28 16:41:47
题目描述
查找序列a 中小于 b 的第 i 个数的数的个数
输入
输入有多组,每组四行
第一行:序列a个数N
第二行:(序列a的)N个数,升序排列
第三行:序列b个数M
第一行:序列a个数N
第二行:(序列a的)N个数,升序排列
第三行:序列b个数M
第四行:(序列b的)M个数,升序排列
第五行:i 表示b中第i个数
输出
对序列a ,输出小于 b 的第 i 个数的数的个数
样例输入
3
1 2 3
4
1 2 3 4
4
样例输出
3
来源
#include<algorithm>
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int n=;
while(cin>>n)
{
int m=,a[],b[],key=
for(int i=;i<n;i++)
cin>>a[i];
cin>>m;
for(int i=;i<m;i++)
cin>>b[i];
cin>>key;
int num=b[key-],count=;
if(a[]>=num)
{
cout<<""<<endl;
continue;
}
int *t=lower_bound(a,a+n,num);
for(int i=;a[i]<*t;i++)
{
count++;
}
cout<<count<<endl;
}
return ;
}
最新文章
- Android logcat
- 【云计算】Docker删除名称为none的Image镜像
- spring security的标签库
- DJANGO模板的BLOCK自定义技巧
- ubuntu卸载qq2012
- app被Rejected 的各种原因翻译(转)
- JQ N级导航
- STM32/GD32芯片信息(转)
- UVa 103 - Stacking Boxes
- jQuery noConflict() 方法----与其他javaScript插件冲突时
- Quill 富文本编辑器
- 工厂方法 Factory Method
- round函数解决oracle报错";OCI-22053: 溢出错误";的问题
- alpha冲刺5/10
- Oracle Linux下载教程(以Oracle Linux 6.9为例)
- RHEL7-openldap安装配置二(客户端安装配置)
- 进程防结束之PS_CROSS_THREAD_FLAGS_SYSTEM
- Linux系列-Xshell连接本地VMware安装的Linux虚拟机
- ip: either ";dev"; is duplicate, or ";type"; is garbage
- 字符编码 ASCII,Unicode和UTF-8的关系