iarcs list of books TLE, HELP!!!!

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);
        }
}

Use something like a set to keep track of things, using vector::erase gives TLE as that is O(n)!

could you elaborate ?? Could you explain how I should do it with sets??