#include <bits/stdc++.h> using namespace std; #define ll long long #define p_b push_back #define m_p make_pair #define fi first #define se second ll inf = 8000000000000000000; ll mod = 30000; const int maxn = 200003; int main(){ ios_base::sync_with_stdio(0); int n, k; cin>>n>>k; vector<int> t(n); for(int i = 0; i<n; i++) cin>>t[i]; sort(t.begin(), t.end(), greater<int>()); int d = 0; for(int i = k; i<n && t[i-1]==t[i]; i++) d++; cout<<k+d; }
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 | #include <bits/stdc++.h> using namespace std; #define ll long long #define p_b push_back #define m_p make_pair #define fi first #define se second ll inf = 8000000000000000000; ll mod = 30000; const int maxn = 200003; int main(){ ios_base::sync_with_stdio(0); int n, k; cin>>n>>k; vector<int> t(n); for(int i = 0; i<n; i++) cin>>t[i]; sort(t.begin(), t.end(), greater<int>()); int d = 0; for(int i = k; i<n && t[i-1]==t[i]; i++) d++; cout<<k+d; } |