Codeforces 456A Laptops(水题)
2014-08-09 11:32
274 查看
题目链接:Codeforces 456A Laptops
题目大意:给定一些电脑的价格和质量,问是否存在两台电脑a和b,a的价格大于b,但是质量小于b。
解题思路:开一个数组,记录对应价格的最小质量,然后从价格大的开始枚举,维护质量出现的最低值,如果当前质量大于最低值,则存在。
题目大意:给定一些电脑的价格和质量,问是否存在两台电脑a和b,a的价格大于b,但是质量小于b。
解题思路:开一个数组,记录对应价格的最小质量,然后从价格大的开始枚举,维护质量出现的最低值,如果当前质量大于最低值,则存在。
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn = 1e5+5; const int INF = 0x3f3f3f3f; int n, p, q, c[maxn]; bool judge () { int ans = INF; for (int i = 1e5; i >= 0; i--) { if (c[i] == INF) continue; if (c[i] > ans) return true; ans = c[i]; } return false; } int main () { scanf("%d", &n); memset(c, INF, sizeof(c)); for (int i = 0; i < n; i++) { scanf("%d%d", &p, &q); c[p] = min(c[p], q); } printf("%s\n", judge() ? "Happy Alex" : "Poor Alex"); return 0; }
相关文章推荐
- Codeforces Good Bye 2015 A. New Year and Days 水题
- codeforces 685A (水题)
- Number of Ways--CodeForces 466C 水题
- Codeforces 399A Pages(水题)
- CodeForces 682B Alyona and Mex (题意水题)
- CodeForces 614A(水题)
- Codeforces 535B Tavas and SaDDas 水题一枚
- codeforces 733D (水题)
- Codeforces 622B The Time 【水题】
- codeforces水题100道 第十四题 Codeforces Round #321 (Div. 2) A. Kefa and First Steps (brute force)
- codeforces水题100道 第二十六题 Codeforces Beta Round #95 (Div. 2) A. cAPS lOCK (strings)
- codeforces 266A Stones on the Table(模拟水题)
- Codeforces 629B Far Relative’s Problem 【水题】
- Codeforces 712A Memory and Crow 水题
- CodeForces 289A Polo the Penguin and Segments (水题)
- Codeforces 652B z-sort【水题】
- CodeForces 743A Vladik and flights (水题)
- 【水题】CodeForces - 233A Perfect Permutation
- CodeForces 597A Divisibility(水题)(作死的二分)
- Codeforces 365(Div.2)A.Mishka and Game【水题】