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
// Example program
#include <iostream>
#include <string>
using namespace std;
 int tab[2000], n, l,m,ip,maxl;

int main()
{
    cin >>n>>l;
 for (int i = 1; i <= n; i++) 
 {
 cin  >> tab[i];
 if (tab[i]>m) {m=tab[i]; ip=i;}
 }
 
 //cout <<  m;
 tab[ip]=0;
 maxl=1;

for(int j=1;j<l;j++)
{
 m=0;
 for (int i = 1; i <= n; i++) 
 {
 if (tab[i]>m) {m=tab[i]; ip=i;}
 }
 tab[ip]=0;
 maxl++;
}

 for (int i = 1; i <= n; i++) if(tab[i]==m)maxl++;
cout <<maxl;
}