Problem link-Click here
an accepted code is as follows:
#include<bits/stdc++.h>
using namespace std;
vector<int> v[1000015];
int main()
{
int n,m;
for(int i=0;i<1000015;i++)
{
v[i].clear();
}
while(cin>>n>>m)
{
int i=0,t,k,u;
while(n--)
{
cin>>t;
v[t].push_back(i+1);
i++;
}
while(m--)
{
cin>>k>>u;
if(v[u].size()<k)
{
cout<<0<<endl;
}
else
{
cout<<v[u][k-1]<<endl;
}
}
}
return 0;
}
an accepted code is as follows:
#include<bits/stdc++.h>
using namespace std;
vector<int> v[1000015];
int main()
{
int n,m;
for(int i=0;i<1000015;i++)
{
v[i].clear();
}
while(cin>>n>>m)
{
int i=0,t,k,u;
while(n--)
{
cin>>t;
v[t].push_back(i+1);
i++;
}
while(m--)
{
cin>>k>>u;
if(v[u].size()<k)
{
cout<<0<<endl;
}
else
{
cout<<v[u][k-1]<<endl;
}
}
}
return 0;
}
No comments:
Post a Comment