Unable to know what's going wrong with the problem

#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int t,q,a[1000],x,s[100];
	cin>>t;
	for(int i=0;i<t;i++){
		cin>>a[i];
	}
	sort(a,a+t);
	cin>>q;
	for(int i=0;i<q;i++){
		cin>>x;
		s[i]=x;
	}
	for(int i=0;i<q;i++){
		auto lb = lower_bound(a,a+t,s[i])-a;
		auto ub = upper_bound(a,a+t,s[i])-a;
		auto n = ub-lb;
		if(n==0){
			cout<<"-1 -1"<<endl;
		}else if(n==1){
			cout<<lb<<" "<<lb<<endl;
		}else{
			cout<<lb<<" "<<<<endl;
		}
	}
	
}

I tried reading various articles of the above problem but I can’t understand one thing why instead of using C++ STL they are going for more lines of code and the above code is unable to generate the 2nd part of the output for each integer correctly.So some guidance needed here.