#1223 : 不等式

Time Limit: 1 Sec

Memory Limit: 256 MB

题目连接

http://hihocoder.com/problemset/problem/1223

Description

给定n个关于X的不等式,问最多有多少个成立。

每个不等式为如下的形式之一:

X < C

X <= C

X = C

X > C

X >= C

Input

第一行一个整数n。

以下n行,每行一个不等式。

数据范围:

1<=N<=50,0<=C<=1000

Output

一行一个整数,表示最多可以同时成立的不等式个数。

Sample Input

4
X = 1
X = 2
X = 3
X > 0

Sample Output

2

HINT

 

题意

题解:

直接枚举每一个数就好了,对于每一个数,判断有多少个数据是满足的

当然对于数据范围比较大的题的话,那就得离散化加区间更新呢,最后查询最大值就好了

总体来说思路是一样的

代码:

  1. //qscqesze
  2. #include <cstdio>
  3. #include <cmath>
  4. #include <cstring>
  5. #include <ctime>
  6. #include <iostream>
  7. #include <algorithm>
  8. #include <set>
  9. #include <bitset>
  10. #include <vector>
  11. #include <sstream>
  12. #include <queue>
  13. #include <typeinfo>
  14. #include <fstream>
  15. #include <map>
  16. #include <stack>
  17. typedef long long ll;
  18. using namespace std;
  19. //freopen("D.in","r",stdin);
  20. //freopen("D.out","w",stdout);
  21. #define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
  22. #define maxn 1200051
  23. #define mod 10007
  24. #define eps 1e-9
  25. int Num;
  26. //const int inf=0x7fffffff; //нчоч╢С
  27. const int inf=~0u>>;
  28. inline ll read()
  29. {
  30. ll x=,f=;char ch=getchar();
  31. while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
  32. while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
  33. return x*f;
  34. }
  35. //**************************************************************************************
  36.  
  37. string str[],X;
  38. int num[];
  39. int main()
  40. {
  41. int n=read();
  42. for(int i=;i<=n;i++)
  43. {
  44. cin>>X>>str[i]>>num[i];
  45. num[i]*=;
  46. }
  47. int ans=;
  48. for(int i=-;i<=;i++)
  49. {
  50. int tmp = ;
  51. for(int j=;j<=n;j++)
  52. {
  53. int ok = ;
  54. if(str[j]=="<")
  55. if(i>=num[j])
  56. ok=;
  57. if(str[j]=="<=")
  58. if(i>num[j])
  59. ok=;
  60. if(str[j]=="=")
  61. if(i!=num[j])
  62. ok=;
  63. if(str[j]==">")
  64. if(i<=num[j])
  65. ok=;
  66. if(str[j]==">=")
  67. if(i<num[j])
  68. ok=;
  69. if(ok)
  70. tmp++;
  71. }
  72. ans=max(tmp,ans);
  73. }
  74. printf("%d\n",ans);
  75. }

hihocoder #1223 : 不等式 水题的更多相关文章

  1. [hihoCoder]1014 Trie水题

    最最最最最最最基本的Trie词频统计应用了. package trie; import java.util.Scanner; public class Main { public static voi ...

  2. hihocoder 1322 - 树结构判定 - [hiho一下161周][模板题/水题]

    题目链接:http://hihocoder.com/problemset/problem/1322 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 给定一个包含 N 个顶 ...

  3. HDU 4950 Monster (水题)

    Monster 题目链接: http://acm.hust.edu.cn/vjudge/contest/123554#problem/I Description Teacher Mai has a k ...

  4. POJ 水题(刷题)进阶

    转载请注明出处:優YoU http://blog.csdn.net/lyy289065406/article/details/6642573 部分解题报告添加新内容,除了原有的"大致题意&q ...

  5. ACM_一道耗时间的水题

    一道耗时间的水题 Time Limit: 2000/1000ms (Java/Others) Problem Description: Do you know how to read the phon ...

  6. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  7. ACM :漫漫上学路 -DP -水题

    CSU 1772 漫漫上学路 Time Limit: 1000MS   Memory Limit: 131072KB   64bit IO Format: %lld & %llu Submit ...

  8. ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)

    1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 154  Solved: 112[ ...

  9. [poj2247] Humble Numbers (DP水题)

    DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...

随机推荐

  1. 【转】Windows环境下Android Studio v1.0安装教程

    原文网址:http://ask.android-studio.org/?/article/9 http://android-studio.org/index.php/docs/experience/1 ...

  2. ioctl用法详解 (网络)

    本函数影响由fd参数引用的一个打开的文件. #include#include int ioctl( int fd, int request, .../* void *arg */ );返回0:成功   ...

  3. Linux 中直接 I/O 机制的介绍

    https://www.ibm.com/developerworks/cn/linux/l-cn-directio/ 对于传统的操作系统来说,普通的 I/O 操作一般会被内核缓存,这种 I/O 被称作 ...

  4. MYSQL内存

    全局内存(BASE MEMORY) 线程内存(MEMORY PER CONNECTION) max_conecctions:整个 MySQL 允许的最大连接数; max_user_connection ...

  5. Android下载速度计算

    long startTime = System.currentTimeMillis(); // 开始下载时获取开始时间 long curTime = System.currentTimeMillis( ...

  6. cocos2d-x 添加背景音乐和音效-SimpleAudioEngine

    首先,要想使用音效,需要启用音效引擎库CocosDenshion中的SimpleAudioEngine类, #include "SimpleAudioEngine.h" Cocos ...

  7. 【转】javascript-图片预加载技术

    1,脚本代码: /** * 图片头数据加载就绪事件 - 更快获取图片尺寸 * @version 2011.05.27 * @author TangBin * @see http://www.plane ...

  8. Python 变量 对象 引用

    1.变量 变量第一次赋值时被创建,变量在使用前必须赋值 变量本身没有类型,变量类型为它引用的对象类型: 变量在使用时被替换成它引用的对象 2.对象 对象本身具有计数和类型,变量引用对象,当对象的引用变 ...

  9. mybatis系列-09-订单商品数据模型

    9.1     数据模型分析思路 1.每张表记录的数据内容 分模块对每张表记录的内容进行熟悉,相当 于你学习系统 需求(功能)的过程. 2.每张表重要的字段设置 非空字段.外键字段 3.数据库级别表与 ...

  10. 【转】Maven实战(一)---Maven Build--缺少Jar包

    原博文出于: http://blog.csdn.net/liutengteng130/article/details/41426955   感谢! 新建的Maven项目,在build的时候总是打包失败 ...