Codeforces Round #260 (Div. 2)A. Laptops
1 second
256 megabytes
standard input
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.
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.
If Alex is correct, print "Happy Alex", otherwise print "Poor Alex" (without the quotes).
2
1 2
2 1
Happy Alex
题目告诉。给出n个电脑,每一个电脑一个价钱和价值,问有没有存在价钱更低。价值更高的,sad。。
。。一開始还想要排序神马的,越想越乱。最后发现 输入的ai和bi都是不同的,而且都在1到n的范围内,也就是说每一个数仅仅会出现一次,那么仅仅有 a[1] =1 a[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\n");
else
printf("Poor Alex\n"); }
return 0;
}
Codeforces Round #260 (Div. 2)A. Laptops的更多相关文章
- DP Codeforces Round #260 (Div. 1) A. Boredom
题目传送门 /* 题意:选择a[k]然后a[k]-1和a[k]+1的全部删除,得到点数a[k],问最大点数 DP:状态转移方程:dp[i] = max (dp[i-1], dp[i-2] + (ll) ...
- 递推DP Codeforces Round #260 (Div. 1) A. Boredom
题目传送门 /* DP:从1到最大值,dp[i][1/0] 选或不选,递推更新最大值 */ #include <cstdio> #include <algorithm> #in ...
- Codeforces Round #260 (Div. 2)AB
http://codeforces.com/contest/456/problem/A A. Laptops time limit per test 1 second memory limit per ...
- Codeforces Round #260 (Div. 2)
A. Laptops 题目意思: 给定n台电脑,第i台电脑的价格是ai ,质量是bi ,问是否存在一台电脑价格比某台电脑价格底,但质量确比某台电脑的质量高,即是否存在ai < aj 且 bi & ...
- Codeforces Round #260 (Div. 2) A
Description One day Dima and Alex had an argument about the price and quality of laptops. Dima think ...
- Codeforces Round #260 (Div. 2) A B C 水 找规律(大数对小数取模) dp
A. Laptops time limit per test 1 second memory limit per test 256 megabytes input standard input out ...
- Codeforces Round #260 (Div. 2) A~C
题目链接 A. Laptops time limit per test:1 secondmemory limit per test:256 megabytesinput:standard inputo ...
- Codeforces Round #260 (Div. 1) D. Serega and Fun 分块
D. Serega and Fun Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/455/pro ...
- Codeforces Round #260 (Div. 1) C. Civilization 并查集,直径
C. Civilization Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/455/probl ...
随机推荐
- mysql 数据库 备份 还原
参考资料: http://blog.51yip.com/mysql/139.html
- 结合tcpdump命令对traceroute深入分析
昨天突然被问到traceroute的原理,一时竟也说不出来,有些命令平时虽然经常在用,但实际原理确并不了解,趁这次机会就来梳理一下. traceroute:是网络诊断中,用来分析IP包经过那些路由的命 ...
- mybatis的缓存机制
一级缓存: MyBatis的一级缓存指的是在一个Session域内,session为关闭的时候执行的查询会根据SQL为key被缓存(跟mysql缓存一样,修改任何参数的值都会导致缓存失效) packa ...
- .net对文件的操作之文件读写
读写文件的步骤一般需要5步: 创建文件流 创建读写器 执行读或写的操作 关闭读写器 关闭文件流 需要引用:System.IO这个命名空间 代码演示: string path = @"F:\a ...
- C#如何判断质数(转)
要求:重复让用户输入输入一个数,判断该数是否质数,当输入“q”时,程序运行结束!(质数的判断要求用方法来实现). class Program { static void Main(string[] a ...
- Set,Map数据结构
/*Set : 多个value的集合, value不重复Map : 多个key-value对的集合, key不重复 1. Set容器 1). Set() 2). Set(array) 3). add( ...
- 12 hdfs常用文件、目录拷贝操作、删除操作
package com.da.hbase.tool.utils; import com.da.hbase.tool.common.Const; import org.apache.hadoop.con ...
- 包装 request Demo
//包装request,增强getParameter方法 class MyReq extends HttpServletRequestWrapper{ private HttpServletReque ...
- GDI相关基础知识
原文链接:http://blog.csdn.net/poem_qianmo/article/details/7333886 GDI(Graphics Device Interface) 图形设备接口, ...
- 一个简单C程序的汇编代码分析
几个重要的寄存器 eip - 用于存放当前所执行的指令地址 esp - 栈(顶)指针寄存器 ebp - 基址(栈底)指针寄存器 简单的C程序 int g(int x) { ; } int f(int ...