#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

 

题意

题解:

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

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

总体来说思路是一样的

代码:

//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <bitset>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 1200051
#define mod 10007
#define eps 1e-9
int Num;
//const int inf=0x7fffffff; //нчоч╢С
const int inf=~0u>>;
inline ll read()
{
ll x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
}
//************************************************************************************** string str[],X;
int num[];
int main()
{
int n=read();
for(int i=;i<=n;i++)
{
cin>>X>>str[i]>>num[i];
num[i]*=;
}
int ans=;
for(int i=-;i<=;i++)
{
int tmp = ;
for(int j=;j<=n;j++)
{
int ok = ;
if(str[j]=="<")
if(i>=num[j])
ok=;
if(str[j]=="<=")
if(i>num[j])
ok=;
if(str[j]=="=")
if(i!=num[j])
ok=;
if(str[j]==">")
if(i<=num[j])
ok=;
if(str[j]==">=")
if(i<num[j])
ok=;
if(ok)
tmp++;
}
ans=max(tmp,ans);
}
printf("%d\n",ans);
}

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. protobuf-3.0.0-beta-2 windows编译 x64/x86

    V3.0.0 beta2以及之后都是CMake 创建VS Solution,project. 因为只能创建x64的项目工程,有时候需要x86的, 只能创建完x64后,自己修改工程配置弄成x86. 创建 ...

  2. Selenium用户扩展

    Selenium用户扩展 这很容易扩展Selenium IDE加入自定义操作,断言和定位,策略,这是通过添加方法,在JavaScript的帮助下Selenium 对象原型.在启动时,Selenium会 ...

  3. memcpy、memmove、memset及strcpy函数实现和理解

    memcpy.memmove.memset及strcpy函数实现和理解 关于memcpy memcpy是C和C++ 中的内存拷贝函数,在C中所需的头文件是#include<string.h> ...

  4. bzoj 3675 [Apio2014]序列分割(斜率DP)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=3675 [题意] 将n个数的序列分割k次,每次的利益为分割后两部分数值和的积,求最大利益 ...

  5. jQuery/CSS3大屏下拉菜单 自定义子菜单内容

    这是一款样式很酷的jQuery/CSS3下拉菜单,首先这款CSS3菜单是宽屏的,主要是下拉菜单非常大气,更重要的是,下拉菜单的内容可以自己定义,也就是说,下拉菜单中可以定义菜单.图片等HTML元素,是 ...

  6. hive优化之------控制hive任务中的map数和reduce数

    一.    控制hive任务中的map数: 1.    通常情况下,作业会通过input的目录产生一个或者多个map任务. 主要的决定因素有: input的文件总个数,input的文件大小,集群设置的 ...

  7. 集群——LVS理论(转)

    原文:http://caduke.blog.51cto.com/3365689/1544229 当单个服务器性能 不能满足日益增多访问流量时,服务器的扩展策略: Scale Up :向上扩展,提升单个 ...

  8. work3

    HOMEWORK-03 红字部分为组员修改的意见 文件介绍 在EXE文件夹中的main.exe文件为本项目执行文件直接点击即可,CODE文件夹中的C文件夹中包含了算法部分的代码,其编译出的DLL文件在 ...

  9. 递归算法,JavaScript实现

    我们先来看一下定义.递归算法,是将问题转化为规模缩小的同类问题的子问题,每一个子问题都用一个同样的算法去解决.一般来说,一个递归算法就是函数调用自身去解决它的子问题. 递归算法的特点: 在函数过程中调 ...

  10. ocp 1Z0-051 106-140题解析

    106. Examine the data inthe LIST_PRICE and MIN_PRICE columns of the PRODUCTS table: LIST_PRICE MIN_P ...