codeforces600B

sol:简单题,复习一下upper_bound

codeforces600B
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
inline ll read()
{
    ll s=0; bool f=0; char ch=' ';
    while(!isdigit(ch)) {f|=(ch=='-'); ch=getchar();}
    while(isdigit(ch)) {s=(s<<3)+(s<<1)+(ch^48); ch=getchar();}
    return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
    if(x<0) {putchar('-'); x=-x;}
    if(x<10) {putchar(x+'0'); return;}
    write(x/10); putchar((x%10)+'0');
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('\n')
const int N=200005;
int n,m,a[N],b[N];
int main()
{
    int i;
    R(n); R(m);
    for(i=1;i<=n;i++) R(a[i]);
    for(i=1;i<=m;i++) R(b[i]);
    sort(a+1,a+n+1);
    for(i=1;i<=m;i++)
    {
        W(upper_bound(a+1,a+n+1,b[i])-a-1);
    }
    return 0;
}
View Code

 

上一篇:Java中各种O的命名方法


下一篇:XCTF-MISC-新手区-功夫再高也怕菜刀