1 1 1
1000000000
2 1
 20 2 15
12698951 55128070 116962690 156763505 188535242 194018601 269939893 428710623 442819431 483000923 516768937 552903993 633087286 656092270 671535141 714291344 717660646 846508634 879748146 937368929
2 7
1 2
2 4
1 19
1 12
1 5
2 18
2 11
1 16
2 1
2 3
2 19
1 17
2 9
2 6
 6 3 10
62417580 78150524 410053501 582708235 630200761 760672946
2 2
1 5
1 2
1 4
2 4
2 1
2 1
1 6
2 5
2 6

NO
 NO
NO
NO
NO
NO
NO
YES
NO
NO
 NO
YES
NO
NO
YES
YES

#include <stdio.h>
#include <stdlib.h>

typedef struct Bear {
    int active, relation;
} Bear;

Bear *pop(Bear **heap, int count);
void push(Bear **heap, int count, Bear *b);
void sift_up(Bear **heap, int start, int end);
void sift_down(Bear **heap, int start, int end);
void swap(Bear **heap, int a, int b);

/*
 * http://codeforces.com/contest/658/problem/B
 */
int main()
{
    int n = 0, k = 0, q = 0;
    scanf("%d%d%d", &n, &k, &q);

    Bear *t = calloc(n, sizeof(Bear));
    for (int i = 0; i < n; i++) {
        scanf("%d", &t[i].relation);
    }

    Bear **h = calloc(n, sizeof(Bear *));

    int c = 0, d = 0, hs = 0;
    for (int i = 0; i < q; i++) {
        scanf("%d%d", &c, &d);

        if (c == 1) {
            if (hs == k) {
                Bear *b = pop(h, hs--);
                b->active = 0;
            }

            push(h, hs++, &t[d - 1]);
            t[d - 1].active = 1;
        } else {
            if (t[d - 1].active) {
                printf("YES\n");
            } else {
                printf("NO\n");
            }
        }
    }
    return 0;
}

Bear *pop(Bear **heap, int count)
{
    Bear *root = heap[0];

    heap[0] = heap[count - 1];
    sift_down(heap, 0, count - 2);

    return root;
}

void sift_down(Bear **heap, int start, int end)
{
    int root = start, swap_index = start, child = start * 2 + 1;

    while (child <= end) {
        if (heap[swap_index]->relation > heap[child]->relation) {
            swap_index = child;
        }
        if (child + 1 <= end && heap[swap_index]->relation > heap[child + 1]->relation) {
            swap_index = child + 1;
        }
        if (root != swap_index) {
            swap(heap, root, swap_index);
            root = swap_index;
            child = root * 2 + 1;
        }
        else {
            break;
        }
    }
}

void push(Bear **heap, int count, Bear *b)
{
    heap[count] = b;
    sift_up(heap, 0, count);
}

void sift_up(Bear **heap, int start, int end)
{
    int child = end;

    while (child >= start) {
        int parent = (child - 1) / 2;
        if (heap[parent]->relation > heap[child]->relation) {
            swap(heap, parent, child);
            child = parent;
        }
        else {
            break;
        }
    }
}

void swap(Bear **heap, int a, int b)
{
    Bear *t = heap[a];

    heap[a] = heap[b];
    heap[b] = t;
}
