#include<bits/stdc++.h> using namespace std; int T[2001]; int main () { ios_base::sync_with_stdio(0); int n, k; cin>>n>>k; for (int i = 0; i < n; ++i) cin>>T[i]; sort(T, T+n, greater<int>()); int j = k-1; while (T[k-1] == T[j]) ++j; cout<<j; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | #include<bits/stdc++.h> using namespace std; int T[2001]; int main () { ios_base::sync_with_stdio(0); int n, k; cin>>n>>k; for (int i = 0; i < n; ++i) cin>>T[i]; sort(T, T+n, greater<int>()); int j = k-1; while (T[k-1] == T[j]) ++j; cout<<j; return 0; } |