#include <iostream>
#include <algorithm>
using namespace std;
int punkty[2002];
bool mniejsze(int a, int b)
{
if(a>b)
return 1;
return 0;
}
int main()
{
int n,k, licz=0;
cin>>n>>k;
for(int i=0; i<n; i++)
{
cin>>punkty[i];
}
sort(punkty,punkty+n, mniejsze);
for(int i=k-1; i<n; i++)
{
if(punkty[i]==punkty[i+1])
{
licz++;
}
else
break;
}
cout<<k+licz;
}
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 | #include <iostream> #include <algorithm> using namespace std; int punkty[2002]; bool mniejsze(int a, int b) { if(a>b) return 1; return 0; } int main() { int n,k, licz=0; cin>>n>>k; for(int i=0; i<n; i++) { cin>>punkty[i]; } sort(punkty,punkty+n, mniejsze); for(int i=k-1; i<n; i++) { if(punkty[i]==punkty[i+1]) { licz++; } else break; } cout<<k+licz; } |
English