zoukankan      html  css  js  c++  java
  • cidefirces Educational Codeforces Round 2 B Queries about less or equal elements

    B. Queries about less or equal elements

     
     

    You are given two arrays of integers a and b. For each element of the second array bj you should find the number of elements in array a that are less than or equal to the value bj.

    Input

    The first line contains two integers n, m (1 ≤ n, m ≤ 2·105) — the sizes of arrays a and b.

    The second line contains n integers — the elements of array a ( - 109 ≤ ai ≤ 109).

    The third line contains m integers — the elements of array b ( - 109 ≤ bj ≤ 109).

    Output

    Print m integers, separated by spaces: the j-th of which is equal to the number of such elements in array a that are less than or equal to the value bj.

    Sample test(s)
    Input
    5 4
    1 3 5 7 9
    6 4 2 8
    Output
    3 2 1 4
    Input
    5 5
    1 2 1 2 5
    3 1 4 1 5
    Output
    4 2 4 2 5
     1 #include<cstdio>
     2 #include<vector>
     3 #include<cmath>
     4 #include<queue>
     5 #include<map>
     6 #include<cstring>
     7 #include<algorithm>
     8 using namespace std;
     9 typedef long long ll;
    10 typedef unsigned long long ull;
    11 const int maxn=2e5+5;
    12 int main()
    13 {
    14     int n,m;
    15     int a[maxn];
    16     scanf("%d%d",&n,&m);
    17     for(int i=0;i<n;i++)
    18         scanf("%d",&a[i]);
    19     sort(a,a+n);
    20     for(int i=0;i<m;i++)
    21     {
    22         int tt;
    23         scanf("%d",&tt);
    24         int pos=lower_bound(a,a+n,tt+1)-a;
    25         printf("%d ",pos);
    26     }
    27     return 0;
    28 }
  • 相关阅读:
    PL/SQL Developer保存自定义界面布局
    SQL Server 2008中SQL增强之二:Top新用途
    泛型和集合
    Go语言
    软件架构师培训
    using的几种用法
    【十五分钟Talkshow】如何善用你的.NET开发环境
    心的感谢
    【缅怀妈妈系列诗歌】之四:妈妈,对不起
    PDA开发经验小结 (转共享)
  • 原文地址:https://www.cnblogs.com/homura/p/5002171.html
Copyright © 2011-2022 走看看