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
#include <bits/stdc++.h>
using namespace std;
int main()
{
    short n,k;
    cin>>n>>k;
    short y=k;
    vector<short> punkty;
    for(short o=0;o<n;o++)
    {
        short v;
        cin>>v;
        punkty.push_back(v);
    }
    for(short o=1;o<n;o++)
    {
        short x=punkty[o];
        short u=o-1;
        while(u>=0&&punkty[u]<x)
        {
            punkty[u+1]=punkty[u];
            u--;
        }
        punkty[u+1]=x;
    }
    while(punkty[k]==punkty[k-1])
    {
        y++;
        k++;
    }
    cout<<y;

    return 0;
}