1 solutions

  • 0
    @ 2023-9-26 16:47:34

    #include<bits/stdc++.h> using namespace std; const int MAXN = 1e6 + 5; int a[MAXN],n,m,b[MAXN],k; int main(){ scanf("%d %d",&n,&m); for(int i=1;i<=n;i++){ scanf("%d",&a[i]); } for(int j=1;j<=m;j++){ scanf("%d",&b[j]); } for(int j=1;j<=m;j++){ k=lower_bound(a+1,a+n+1,b[j]) - a; if(a[k]!=b[j]){ b[j]=-1; }else{ b[j]=k; } } for(int j=1;j<=m;j++){ printf("%d ",b[j]); } return 0; }

    • 1

    Information

    ID
    4721
    Time
    1000ms
    Memory
    125MiB
    Difficulty
    2
    Tags
    # Submissions
    208
    Accepted
    54
    Uploaded By