@@ -0,0 +1,1519 @@
+// http://codeforces.com/problemset/problem/456/A%0A%0Aimport java.util.ArrayList;%0Aimport java.util.Collections;%0Aimport java.util.Comparator;%0Aimport java.util.List;%0Aimport java.util.Scanner;%0A%0Apublic class Solution %7B%0A%09%0A%09static class LaptopPair %7B%0A%09%09private int price;%0A%09%09private int quality;%0A%09%09%0A%09%09public LaptopPair(int price, int quality) %7B%0A%09%09%09this.price = price;%0A%09%09%09this.quality = quality;%0A%09%09%7D%0A%09%09%0A%09%09public int getPrice() %7B return price; %7D%0A%09%09public int getQuality() %7B return quality; %7D%0A%09%7D%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09Scanner read = new Scanner(System.in);%0A%09%09%0A%09%09int n = read.nextInt();%0A%09%09%0A%09%09// Add to list%0A%09%09List%3CLaptopPair%3E laptopPairs = new ArrayList%3CLaptopPair%3E();%0A%09%09for (int i = 0; i %3C n; ++i) %7B%0A%09%09%09int a = read.nextInt();%0A%09%09%09int b = read.nextInt();%0A%09%09%09laptopPairs.add(new LaptopPair(a, b));%0A%09%09%7D%0A%09%09%0A%09%09// Sort list%0A%09%09Collections.sort(laptopPairs, new Comparator%3CLaptopPair%3E() %7B%0A%09%09%09@Override%0A%09%09%09public int compare(LaptopPair firstPair, LaptopPair secondPair) %7B%0A%09%09%09%09if ( firstPair.getPrice() %3E secondPair.getPrice() ) %7B%0A%09%09%09%09%09return 1;%0A%09%09%09%09%7D%0A%09%09%09%09else %7B%0A%09%09%09%09%09return -1;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D);%0A%09%09%0A%09%09// Check if Alex is right%0A%09%09boolean alexIsCorrect = false;%0A%09%09for (int i = 0; i %3C laptopPairs.size()-1; ++i) %7B%0A%09%09%09if ( laptopPairs.get(i).getQuality() %3E laptopPairs.get(i+1).getQuality() ) %7B%0A%09%09%09%09alexIsCorrect = true;%0A%09%09%09%09break;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09// Print end result%0A%09%09if (alexIsCorrect) %7B%0A%09%09%09System.out.println(%22Happy Alex%22);%0A%09%09%7D%0A%09%09else %7B%0A%09%09%09System.out.println(%22Poor Alex%22);%0A%09%09%7D%0A%09%09%0A%09%09// Close scanner%0A%09%09read.close();%0A%09%7D%0A%09%0A%7D%0A

Create Laptops.java