#include <iostream> #include <algorithm> using namespace std; int n, m, id; int t[2001]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for(int i = 0, w1; i < n; i++) cin >> t[i]; sort(t, t+n); m = n-m; while(t[m-1]==t[m]) m--; cout << n-m; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #include <iostream> #include <algorithm> using namespace std; int n, m, id; int t[2001]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for(int i = 0, w1; i < n; i++) cin >> t[i]; sort(t, t+n); m = n-m; while(t[m-1]==t[m]) m--; cout << n-m; return 0; } |