Untitled
unknown
c_cpp
3 years ago
478 B
11
Indexable
#include <iostream>
#include <stack>
using namespace std;
const int N = 1e5 + 3;
int n,m,a[N],x;
int main(){
cin >> n >> m;
stack <int> s;
for (int i = n; i > 0; i--){
s.push(i);
}
for (int i = 1; i <= m; i++){
cin >> x;
s.push(x);
}
int i = 0;
for ( ; i < n; ){
if (!a[s.top()]){
cout << s.top() << " ";
a[s.top()] = -1;
i++;
}
s.pop();
}
return 0;
}Editor is loading...