-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeforces1234B1.cpp
More file actions
49 lines (47 loc) · 853 Bytes
/
Codeforces1234B1.cpp
File metadata and controls
49 lines (47 loc) · 853 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mx 1000010
#define pb push_back
#define pf push_front
int main()
{
ll n,i,j,m,t,k;
ll x;
deque<ll>a;
deque<ll>b;
a.clear();
b.clear();
cin>>n>>m;
for(i=0;i<n;i++)
{
cin>>x;
a.pb(x);
}
for(i=0,j=0;i<n;i++)
{
bool flag=1;
for(k=0;k<b.size();k++)
{
if(a[i]==b[k]) {
flag=0;
break;
}
}
if(flag){
if(j==m){
b.pop_back();
j--;
}
b.pf(a[i]);
j++;
}
}
int len=b.size();
cout<<len<<endl;
for(auto it=b.begin();it!=b.end();it++)
{
cout<<*it<<" ";
}
cout<<endl;
}