Skip to content

Instantly share code, notes, and snippets.

@chermehdi
Created January 23, 2018 19:30
Show Gist options
  • Save chermehdi/b3cf5735fbf9e3af413b13c338e3eee4 to your computer and use it in GitHub Desktop.
Save chermehdi/b3cf5735fbf9e3af413b13c338e3eee4 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
using namespace std;
const int N = 500;
const long long mod = 1e9 + 7;
int main(){
int n, p; cin >> n >> p;
set<int> s;
// solve the problem in reverse order
// suppose you already have all the elements of the list
// and a student comes, means we remove it from the set of available students
for(int i = 1; i <= n; i++) s.insert(i);
for(int i = 0; i < p; i++){
int cur; cin >> cur;
auto it = s.find(cur); // find the current
s.erase(it); // remove it
cout << *s.begin() << endl; // get the minimum available student
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment