#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
long long n ; //floors
long long m ; //letters
cin>>n;
cin>>m;
long long total = 0;
vector<long long >a;
for(long long i = 0 ; i<n;i++)
{
long long k;
cin>>k;
total += k;
a.push_back(total);
}
//cin>>m;
vector<long long>b;
for(int i = 0 ; i<m;i++)
{
long long k ;
cin>>k;
b.push_back(k);
}
for(long long i = 0 ; i<m ; i++)
{
long long letter = b[i];
auto f = lower_bound(a.begin() , a.end() , letter) - a.begin();
vector<long long>c;
long long j = (f == 0)?1:a[f-1];
while(j<=a[f])
{
c.push_back(j);
++j;
}
auto r = lower_bound(c.begin() , c.end() , letter) - c.begin();
if(letter<=10)
cout<<f+1<<" "<<r+1<<"\n";
else
cout<<f+1<<" "<<r<<"\n";
}
}
THIS IS MY code but it is having MEMORY LIMIT EXCEEDED
pls guys give a detailed solution code.And also say what is wrong in my code