//Autor: Szymon Nowak
#include <iostream>
#include <algorithm>
using namespace std;
bool porownaj(int a, int b)
{
//sprawdzamy, czy pierwszy element jest większy od drugiego
return a>b;
}
int main()
{
int n,k;
cin>>n>>k;
int punkty[n];
for(int i=0;i<n;i++)
{
cin>>punkty[i];
}
sort(punkty,punkty+n,porownaj);
int ile_koszulek=k;
int j=k;
while(punkty[j]==punkty[k-1] && k<n) {ile_koszulek++; j++;}
cout<<ile_koszulek;
return 0;
}
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 | //Autor: Szymon Nowak #include <iostream> #include <algorithm> using namespace std; bool porownaj(int a, int b) { //sprawdzamy, czy pierwszy element jest większy od drugiego return a>b; } int main() { int n,k; cin>>n>>k; int punkty[n]; for(int i=0;i<n;i++) { cin>>punkty[i]; } sort(punkty,punkty+n,porownaj); int ile_koszulek=k; int j=k; while(punkty[j]==punkty[k-1] && k<n) {ile_koszulek++; j++;} cout<<ile_koszulek; return 0; } |
English