```cpp
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<queue>
using namespace std;
struct tree{int l,r,fa,ln,rn;int num;}tree[100005];
int n,k,a[100005],ans=0,root,tot=0;bool bjj[30005];
void Zag(int x) {
int y=tree[x].fa;
tree[y].r=tree[x].l;
if(tree[x].l)tree[tree[x].l].fa=y;
tree[x].fa=tree[y].fa;
if(tree[y].fa) {
if(tree[tree[y].fa].l==y)tree[tree[y].fa].l=x;
else tree[tree[y].fa].r=x;
}
tree[x].l=y;
tree[y].fa=x;
tree[y].rn=tree[x].ln;
tree[x].ln=tree[y].ln+tree[y].rn+1;
}
void Zig(int x) {
int y=tree[x].fa;
tree[y].l=tree[x].r;
if(tree[x].r)tree[tree[x].r].fa=y;
tree[x].fa=tree[y].fa;
if(tree[y].fa) {
if(tree[tree[y].fa].l==y)tree[tree[y].fa].l=x;
else tree[tree[y].fa].r=x;
}
tree[x].r=y;
tree[y].fa=x;
tree[y].ln=tree[x].rn;
tree[x].rn=tree[y].ln+tree[y].rn+1;
}
void splay(int x)
{
int y;
while(tree[x].fa)
{
y=tree[x].fa;
if(tree[y].fa==0)
{
if(x==tree[y].l)Zig(x);
else Zag(x);
break;
}
if(x==tree[y].l)
{
if(tree[tree[y].fa].l==y){Zig(y);Zig(x);}
else {Zig(x);Zag(x);}
}
else
{
if(tree[tree[y].fa].r==y){Zag(y);Zag(x);}
else {Zag(x);Zig(x);}
}
}
root=x;
}
void Insert(int x)
{
int y=root,z=0;
while(y)
{
z=y;
if(x<=tree[y].num)y=tree[y].l;
else y=tree[y].r;
}
tot++;
tree[tot].num=x;tree[tot].fa=z;
tree[tot].l=tree[tot].r=tree[tot].ln=tree[tot].rn=0;
if(root==0){root=tot;return;}
if(x<=tree[z].num)tree[z].l=tot;
else tree[z].r=tot;
splay(tot);
}
void Findk(int k)
{
int y=root;
if(tree[y].ln+tree[y].rn+1<k){printf("NO RESULT\n");return;}
while(1)
{
if(tree[y].rn+1==k){splay(y);printf("%d\n",tree[y].num);return;}
if(tree[y].rn>=k)y=tree[y].r;
else {k-=tree[y].rn+1;y=tree[y].l;}
}
}
int main()
{
int nn;
scanf("%d %d",&n,&k);nn=n;
for(int i=1;i<=n;i++)
{
int x;scanf("%d",&x);
if(bjj[x]==false){bjj[x]=true;Insert(x);}
else nn--;
}
Findk(nn-k+1);
return 0;
}
```
by wubaiting2020 @ 2019-02-19 16:07:00
splay
by wubaiting2020 @ 2019-02-19 16:28:35
...
by 眠ㅤㅤㅤ @ 2019-02-19 16:43:21
@[wubaiting2020](/space/show?uid=42019) 因为 $NO RESULT$
by 眠ㅤㅤㅤ @ 2019-02-19 16:57:14