#include <iostream>
using namespace std;
int main()
{
int n, k, i, j, max, pom, x;
cin>>n>>k;
int t[n];
for (i=0; i<n; i++)
{
cin>>t[i];
}
for (i=0; i<n; i++)
{
max=0;
for (j=i; j<n; j++)
{
if (t[j]>max)
{
max=t[j];
pom=j;
}
}
swap(t[pom],t[i]);
}
pom=k;
for (i=k-1; i<n; i++) //120 90 75 75 40
{
if (t[i]!=t[i+1])
{
cout<<pom;
return 0;
}
pom++;
}
}
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 35 | #include <iostream> using namespace std; int main() { int n, k, i, j, max, pom, x; cin>>n>>k; int t[n]; for (i=0; i<n; i++) { cin>>t[i]; } for (i=0; i<n; i++) { max=0; for (j=i; j<n; j++) { if (t[j]>max) { max=t[j]; pom=j; } } swap(t[pom],t[i]); } pom=k; for (i=k-1; i<n; i++) //120 90 75 75 40 { if (t[i]!=t[i+1]) { cout<<pom; return 0; } pom++; } } |
English