fork download
  1. #include<bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. using namespace __gnu_pbds;
  4. using namespace std;
  5.  
  6. #define ff first
  7. #define ss second
  8. #define int long long
  9. #define pb push_back
  10. #define mp make_pair
  11. #define pii pair<int,int>
  12. #define vi vector<int>
  13. #define mii map<int,int>
  14. #define pqb priority_queue<int>
  15. #define pqs priority_queue<int,vi,greater<int> >
  16. #define setbits(x) __builtin_popcountll(x)
  17. #define zrobits(x) __builtin_ctzll(x)
  18. #define mod 1000000007
  19. #define inf 1e18
  20. #define ps(x,y) fixed<<setprecision(y)<<x
  21. #define mk(arr,n,type) type *arr=new type[n];
  22. #define w(x) int x; cin>>x; while(x--)
  23. mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  24. typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
  25.  
  26.  
  27. void c_p_c()
  28. {
  29. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  30. #ifndef ONLINE_JUDGE
  31. freopen("/home/krishna/Documents/competitive/input.txt", "r", stdin);
  32. freopen("/home/krishna/Documents/competitive/output.txt", "w", stdout);
  33. #endif
  34. }
  35. bool mycomp(pair<int,string> p1,pair<int,string> p2)
  36. {
  37. if(p1.first>p2.first)
  38. return true;
  39. else if(p1.first<p2.first)
  40. return false;
  41. else
  42. {
  43. if(p1.second<p2.second)
  44. return true;
  45. else
  46. return false;
  47. }
  48. }
  49.  
  50. int32_t main()
  51. {
  52. c_p_c();
  53. int x,n;
  54. cin>>x;
  55. cin>>n;
  56. int salary,cnt=0;
  57. string name;
  58. vector<pair<int,string>> payroll;
  59. payroll.reserve(n);
  60. for(int i=0;i<n;i++)
  61. {
  62. cin>>name>>salary;
  63. if(salary>=x)
  64. {
  65. payroll.push_back(mp(salary,name));
  66. cnt++;
  67. }
  68.  
  69. }
  70. sort(payroll.begin(),payroll.end(),mycomp);
  71. for(auto i: payroll)
  72. cout<<i.first<<" "<<i.second<<endl;
  73.  
  74. return 0;
  75. }
Success #stdin #stdout 0s 4220KB
stdin
79
4
Eve 78
Bob 99
Bab 99
Alice 86
stdout
99 Bab
99 Bob
86 Alice