fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4.  
  5. int main() {
  6. int n,k,p[51],t[51],c[51];
  7. cin>>n>>k;
  8. for(int i=0;i<n;i++){
  9. cin>>p[i]>>t[i];
  10. c[p[i]]=t[i];
  11. }
  12. sort(p,p+n);
  13. reverse(p,p+n);
  14. for(int i=0;i<n;i++){
  15. if(p[i]==p[i+1]){
  16. if(c[p[i]]<c[p[i+1]])
  17. swap(p[i],p[i+1]);
  18. }
  19. }
  20. int x=p[k-1];
  21. int y=c[p[k-1]];
  22. int count=0;
  23. for(int i=0;i<n;i++){
  24. if(p[i]==x&&c[p[i]]==y)
  25. count++;
  26. }
  27. cout<<count;
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0s 3144KB
stdin
50 22
4 9
8 1
3 7
1 2
3 8
9 8
8 5
2 10
5 8
1 3
1 8
2 3
7 9
10 2
9 9
7 3
8 6
10 6
5 4
8 1
1 5
6 8
9 5
9 5
3 2
3 3
3 8
7 5
4 5
8 10
8 2
3 5
3 2
1 1
7 2
2 7
6 8
10 4
7 5
1 7
6 5
3 1
4 9
2 3
3 6
5 8
4 10
10 7
7 10
9 8
stdout
3