fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. int main() {
  6. int n,k,s,p;
  7. cin >> n >> k;
  8. vector<pair<int,int>> vp(n);
  9. map<pair<int,int>,int> mp;
  10. for(int i=0;i<n;i++){
  11. cin >> s >> p;
  12. vp[i] = make_pair(s,-p);
  13. mp[{s,-p}]++;
  14. }
  15.  
  16. sort(vp.begin(),vp.end(),greater<>());
  17. for(auto i:vp){
  18. cout << i.first << " " << i.second << endl;
  19. }
  20. cout << vp[k-1].first << " " << vp[k-1].second << endl;
  21. cout << mp[vp[k-1]];
  22.  
  23. return 0;
  24. }
Success #stdin #stdout 0s 5280KB
stdin
5 4
3 1
3 1
5 3
3 1
3 1
stdout
5 -3
3 -1
3 -1
3 -1
3 -1
3 -1
4