求赞!
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,q,k,a[100010];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>q;
for(ll i=1; i<=n; i++) cin>>a[i];
while(q--) {
cin>>k;
ll tmp=lower_bound(a+1,a+n+1,k)-a;
if(a[tmp]!=k) {
cout<<-1<<" "<<-1<<"\n";
continue;
}
cout<<tmp-1<<" ";
tmp=upper_bound(a+1,a+n+1,k)-a;
cout<<tmp-2<<"\n";
}
return 0;
}