#include <iostream> #include <algorithm> using namespace std; int arr[2002]; int main() { int n, k; std::ios::sync_with_stdio(false); cin >> n >> k; for(int i = 1; i <= n; i++) { cin >> arr[i]; } sort(arr + 1, arr + n + 1); arr[0] = -1; int last_place_without_T_shit = n - k, kth_place = n - k + 1; while(arr[last_place_without_T_shit] == arr[kth_place]) { last_place_without_T_shit--; } cout << n - last_place_without_T_shit; 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 32 33 | #include <iostream> #include <algorithm> using namespace std; int arr[2002]; int main() { int n, k; std::ios::sync_with_stdio(false); cin >> n >> k; for(int i = 1; i <= n; i++) { cin >> arr[i]; } sort(arr + 1, arr + n + 1); arr[0] = -1; int last_place_without_T_shit = n - k, kth_place = n - k + 1; while(arr[last_place_without_T_shit] == arr[kth_place]) { last_place_without_T_shit--; } cout << n - last_place_without_T_shit; return 0; } |