Codeforces Round #260 (Div. 2)A. Laptops
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
One day Dima and Alex had an argument about the price and quality of laptops. Dima thinks that the more expensive a laptop is, the better it is. Alex disagrees. Alex thinks that there are two laptops, such that the price of the first laptop is less (strictly smaller) than the price of the second laptop but the quality of the first laptop is higher (strictly greater) than the quality of the second laptop.
Please, check the guess of Alex. You are given descriptions of n laptops. Determine whether two described above laptops exist.
Input
The first line contains an integer n (1 ≤ n ≤ 105) — the number of laptops.
Next n lines contain two integers each, ai and bi (1 ≤ ai, bi ≤ n), where ai is the price of the i-th laptop, and bi is the number that represents the quality of the i-th laptop (the larger the number is, the higher is the quality).
All ai are distinct. All bi are distinct.
Output
If Alex is correct, print "Happy Alex", otherwise print "Poor Alex"(without the quotes).
Sample test(s)
Input
2
1 2
2 1
Output
Happy Alex
제목은 n개의 컴퓨터를 제시하고, 컴퓨터마다 가격과 가치가 있으며, 가격이 더 낮고, 가치가 더 높은sad가 존재하느냐고 묻는다...처음에는 신마의 순서를 정하려고 했는데 생각할수록 혼란스러워졌다. 마지막에 입력한ai와bi는 모두 다르고 1에서 n의 범위 안에 있다는 것을 발견했다. 즉, 숫자마다 한 번만 나타날 수 있다는 것이다. 그러면 a[1]=1a[2]=2가 있어야만 가격이 낮고 가치가 높은 것이 나타나지 않는다. 하시는 한 번에 훑어보면 된다.sad...15분밖에 안 지났는데...
#include <cstdio>
#include <cstring>
#include <cstring>
#define INF 0x3f3f3f3f
using namespace std;
int p[110000] ;
int main()
{
int i , n , a , b ;
while(scanf("%d", &n)!=EOF)
{
memset(p,-1,sizeof(p));
for(i = 1 ; i <= n ; i++)
{
scanf("%d %d", &a, &b);
p[a] = b ;
}
for(i = 1 ; i <= n ; i++)
if( p[i] != i )
break;
if(i <= n)
printf("Happy Alex
");
else
printf("Poor Alex
");
}
return 0;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.