题目描述

查找序列a 中小于 b 的第 i 个数的数的个数

输入

输入有多组,每组四行
第一行:序列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

来源

2009机考C题

#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 ;
}

最新文章

  1. Android logcat
  2. 【云计算】Docker删除名称为none的Image镜像
  3. spring security的标签库
  4. DJANGO模板的BLOCK自定义技巧
  5. ubuntu卸载qq2012
  6. app被Rejected 的各种原因翻译(转)
  7. JQ N级导航
  8. STM32/GD32芯片信息(转)
  9. UVa 103 - Stacking Boxes
  10. jQuery noConflict() 方法----与其他javaScript插件冲突时
  11. Quill 富文本编辑器
  12. 工厂方法 Factory Method
  13. round函数解决oracle报错&quot;OCI-22053: 溢出错误&quot;的问题
  14. alpha冲刺5/10
  15. Oracle Linux下载教程(以Oracle Linux 6.9为例)
  16. RHEL7-openldap安装配置二(客户端安装配置)
  17. 进程防结束之PS_CROSS_THREAD_FLAGS_SYSTEM
  18. Linux系列-Xshell连接本地VMware安装的Linux虚拟机
  19. ip: either &quot;dev&quot; is duplicate, or &quot;type&quot; is garbage
  20. 字符编码 ASCII,Unicode和UTF-8的关系

热门文章

  1. docker build no such file or directory
  2. VS第一天(一堆错误的错误示范)
  3. Processed foods make us fatter easily
  4. shell中test的使用
  5. BZOJ 1587: 叶子合并leaves
  6. 九度oj 题目1345:XXX定律之画X
  7. VB6 post图片
  8. 【leetcode dp】629. K Inverse Pairs Array
  9. Spring Boot 集成spring security4
  10. 洛谷 [P3205] 合唱队