#define _CRT_SECURE_NO_WARNINGS #include <cstdio> #include <stdio.h> #include <iostream> #include <string.h> #include <math.h> #include <algorithm> #include <vector> const int MAX_POINTS = 120; int main(int argc, char** argv) { int k, n; auto _ = scanf("%d %d", &n, &k); std::vector<int> result; result.resize(MAX_POINTS + 1); result.reserve(MAX_POINTS+1); for(auto i=0;i<n;i++) { int v; int x=scanf("%d", &v); result[v]++; } int ileKos = 0; for (auto it = result.rbegin(); it != result.rend(); ++it) { ileKos += *it; if (ileKos >= k) { break; } } printf("%d\n", ileKos); 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 34 35 36 37 38 39 | #define _CRT_SECURE_NO_WARNINGS #include <cstdio> #include <stdio.h> #include <iostream> #include <string.h> #include <math.h> #include <algorithm> #include <vector> const int MAX_POINTS = 120; int main(int argc, char** argv) { int k, n; auto _ = scanf("%d %d", &n, &k); std::vector<int> result; result.resize(MAX_POINTS + 1); result.reserve(MAX_POINTS+1); for(auto i=0;i<n;i++) { int v; int x=scanf("%d", &v); result[v]++; } int ileKos = 0; for (auto it = result.rbegin(); it != result.rend(); ++it) { ileKos += *it; if (ileKos >= k) { break; } } printf("%d\n", ileKos); return 0; } |