I am Using vectors to erase elements. I am able to get only 60 points. How should I optimise my solution.
Here is my code
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int m,n; cin >> m;
vector<int> vec;
vector<int>::iterator it;
for(int i=0;i<m;i++)
{
int p; cin >> p;
vec.push_back(p);
}
cin >> n;
for(int i=0;i<n;i++)
{
int p; cin >> p;
it = vec.begin()+p-1;
cout << *it << endl;
vec.erase(it);
}
}