#define _CRT_SECURE_NO_WARNINGS 1 #define _WINSOCK_DEPRECATED_NO_WARNINGS 1 #include <iostream> #include <string> using namespace std; int zliczamy[127]; int main() { int n, k; scanf("%d%d", &n, &k); // = {}; while (n-- > 0) { int p; scanf("%d", &p); zliczamy[p]++; } int ile = 0; for (int i = 126; i >0 ; --i) { if (ile >= k) { break; } ile += zliczamy[i]; } printf("%d", ile); }
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 | #define _CRT_SECURE_NO_WARNINGS 1 #define _WINSOCK_DEPRECATED_NO_WARNINGS 1 #include <iostream> #include <string> using namespace std; int zliczamy[127]; int main() { int n, k; scanf("%d%d", &n, &k); // = {}; while (n-- > 0) { int p; scanf("%d", &p); zliczamy[p]++; } int ile = 0; for (int i = 126; i >0 ; --i) { if (ile >= k) { break; } ile += zliczamy[i]; } printf("%d", ile); } |