#define make_pair mp #define emplace_back pb #include <bits/stdc++.h> using namespace std; mt19937 mt_rand(time(0)); const int N = 2005; int n, k, t[N]; int main() { scanf("%d%d", &n, &k); for(int i=1;i<=n;i++) { scanf("%d", &t[i]); } sort(t+1, t+n+1, std::greater<int>()); while(t[k] == t[k+1]) k++; printf("%d\n", k); return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #define make_pair mp #define emplace_back pb #include <bits/stdc++.h> using namespace std; mt19937 mt_rand(time(0)); const int N = 2005; int n, k, t[N]; int main() { scanf("%d%d", &n, &k); for(int i=1;i<=n;i++) { scanf("%d", &t[i]); } sort(t+1, t+n+1, std::greater<int>()); while(t[k] == t[k+1]) k++; printf("%d\n", k); return 0; } |