求助(全RE)

P2249 【深基13.例1】查找

Wooden_head @ 2023-04-13 12:38:34

#include<bits/stdc++.h>
#define next 100000
using namespace std;
long long n,m,num1[next],num2[next];
int ef(int zs){
    int bs=0,es=n-1;
    while(bs<es){
        int zj=(es+bs)/2;
        if(num1[zj]>=num2[zs]) es=zj;
        else bs++;
    }
    if(num1[es]==num2[zs]) return es+1;
    else return 1;
}
int main(){
    cin>>n>>m;
    int j[m];
    for(int s=0;s<n;s++)
        cin>>num1[s];
    for(int s=0;s<m;s++){
        cin>>num2[s];
        j[s]=ef(s);
    }
    for(int s=0;s<m;s++)
        cout<<j[s]<<' ';
    return 0;
}

样例过了,提交就RE


by Wooden_head @ 2023-04-13 12:56:07

2023/4/12


上一页 |