using
System;
using
System.Collections.Generic;
public
class
KthSmallestElement
{
static
void
Operations(
int
[] arr,
int
n,
int
[,] queries,
int
k)
{
List<Pair> s =
new
List<Pair>();
int
j = 0;
for
(j = 0; j < n; j++)
{
s.Add(
new
Pair(arr[j], j));
}
s.Sort();
for
(
int
i = 0; i < k; i++)
{
if
(queries[i, 0] == 1)
{
s.Add(
new
Pair(queries[i, 1], j));
j++;
s.Sort();
}
else
if
(queries[i, 0] == 2)
{
Console.WriteLine(s[queries[i, 1] - 1].first);
}
}
}
public
class
Pair : IComparable<Pair>
{
public
int
first, second;
public
Pair(
int
first,
int
second)
{
this
.first = first;
this
.second = second;
}
public
int
CompareTo(Pair other)
{
return
this
.first.CompareTo(other.first);
}
}
public
static
void
Main(
string
[] args)
{
int
n = 8;
int
[] arr = { 2, 4, 2, 1, 5, 6, 2, 4 };
int
k = 4;
int
[,] queries
= { { 1, 3 }, { 2, 2 }, { 1, 10 }, { 2, 7 } };
Operations(arr, n, queries, k);
}
}