so I have a task. I've been given n numbers and m intervals and I need to figure out how many numbers are in the m i-th interval. I've written some code with a complexity of O(n*m), though I need to optimize it more. Any help? Code:
#include <bits/stdc++.h>
using namespace std;
int main()
{
cin.tie(0);
ios_base::sync_with_stdio(0);
cout.tie(0);
int n,m,temp,temp1;
vector <pair<int, int>> uogienes;
vector <int> erskeciai;
cin >> n >> m;
for (int i = 0; i< n; i++){
cin>>temp;
erskeciai.push_back(temp);
}
temp = 0;
for (int i = 0; i<m; i++){
cin>> temp >> temp1;
uogienes.push_back(make_pair(temp, temp1));
}
for(int i = 0; i<m; i++){
temp=0;
for(int h = 0; h<n; h++){
if(uogienes[i].first <= erskeciai[h] && uogienes[i].second >= erskeciai[h]){
temp++;
}
}
cout << temp << "\n";
}
return 0;
}