456A - Laptops - CodeForces Solution


sortings *1100

Please click on ads to support us..

Python Code:

import os
import sys
import math
from collections import deque, defaultdict
import bisect
import heapq

input = sys.stdin.readline


def multiple():
    a = map(int, input().split())
    return a


def array():
    a = input().split()
    return a


def intarray():
    a = list(map(int, input().split()))
    return a


def intinput():
    n = int(input())
    return n


def strinput():
    s = input().strip()
    return s


def isPrime(n):
    val = int(math.sqrt(n)) + 1
    for i in range(2, val):
        if n % i == 0:
            return False
    return True


def solution():
        MOD = 1000000007
    n = intinput()
    arr=[]
    for i in range(n):
        a,b = multiple()
        arr.append([a,b])
    arr.sort()
    maxsofar = 0
    for i in range(n):
        a,b = arr[i]
        if b <= maxsofar:
            print("Happy Alex")
            return
        maxsofar = b
    print("Poor Alex")
    return


t = 1
for _ in range(t):
        solution()

C++ Code:

#include <iostream>
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int n;
    cin>>n;
    pair<int,int> pr[n];
    for(int i=0;i<n;i++)
    {
        cin>>pr[i].first>>pr[i].second;
    }
    sort(pr,pr+n);
    for(int j=0;j<n-1;j++)
    {
        if(pr[j].first<pr[j+1].first && pr[j].second>pr[j+1].second)
        {
            cout<<"Happy Alex"<<endl;
            return 0;
        }
    }
    cout<<"Poor Alex"<<endl;
    return 0;
}


Comments

Submit
0 Comments
More Questions

1408B - Arrays Sum
1430A - Number of Apartments
1475A - Odd Divisor
1454B - Unique Bid Auction
978C - Letters
501B - Misha and Changing Handles
1496A - Split it
1666L - Labyrinth
1294B - Collecting Packages
1642B - Power Walking
1424M - Ancient Language
600C - Make Palindrome
1669D - Colorful Stamp
1669B - Triple
1669A - Division
1669H - Maximal AND
1669E - 2-Letter Strings
483A - Counterexample
3C - Tic-tac-toe
1669F - Eating Candies
1323B - Count Subrectangles
991C - Candies
1463A - Dungeon
1671D - Insert a Progression
1671A - String Building
1671B - Consecutive Points Segment
1671C - Dolce Vita
1669G - Fall Down
4D - Mysterious Present
1316B - String Modification