Hustlingbeast_Anish

Untitled

Feb 5th, 2022
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
  5. {
  6. return (a.second>b.second);
  7. }
  8.  
  9. int main(){
  10. ios_base::sync_with_stdio(false);
  11. cin.tie(NULL);
  12.  
  13. int n;
  14. cin>>n;
  15. vector< pair<int,int> > vec;
  16. // pair<int,int> p;
  17. // for (int i = 0; i < n; i++)
  18. while(n--)
  19. {
  20. int t,h;
  21. cin>>t>>h;
  22. vec.push_back(make_pair(t,h));
  23. }
  24.  
  25. // For sorting a vector of pairs on the basis of their second value
  26. sort(vec.begin(),vec.end());
  27.  
  28. for(int i=0;i<vec.size()-1;i++){
  29.  
  30. if(vec[i].first<vec[i+1].first && vec[i].second> vec[i+1].second ){
  31. cout<<"Happy Alex"<<endl;
  32. break;
  33. }
  34. else{
  35. cout<<"Poor Alex"<<endl;
  36. break;
  37. }
  38. }
  39.  
  40.  
  41. // for (int i = 0; i < vec.size(); i++)
  42. // {
  43. // cout<<vec[i].first<<" "<<vec[i].second<<endl;
  44. // }
  45.  
  46.  
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment