#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define st first
#define nd second
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define all(a) a.begin(),a.end()
const int mxN = 2e3+7;
int a[mxN];
bool cmp(int x,int y){
if(x > y) return 1;
return 0;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,k; cin >> n >> k;
rep(i,1,n) cin >> a[i];
sort(a+1,a+n+1,cmp);
while(a[k] == a[k+1] && k <= n) k++;
cout << k << "\n";
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define st first #define nd second #define pb push_back #define rep(i,a,b) for(ll i=a;i<=b;i++) #define all(a) a.begin(),a.end() const int mxN = 2e3+7; int a[mxN]; bool cmp(int x,int y){ if(x > y) return 1; return 0; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n,k; cin >> n >> k; rep(i,1,n) cin >> a[i]; sort(a+1,a+n+1,cmp); while(a[k] == a[k+1] && k <= n) k++; cout << k << "\n"; } |
English