#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. ejabberd、jabber、jabberd、xmpp辨析

    Jabber 是著名的即时通讯服务服务器,它是一个自由开源软件,能让用户自己架即时通讯服务器,可以在Internet上应用,也可以在局域网中应用.    XMPP(可扩展消息处理现场协议)是基于可扩展 ...

  2. Matlab编程实例(1) 移动平均

    MATLAB数字信号处理作业,把自己写的程序发上来..欢迎交流~ QQ 五幺九七九零六四   首先是任意点移动平均: 主程序:mov_average_main.m (运行) 函数:mov_averag ...

  3. BLOCK专题

    >>定义并使用一个block    返回值(^名字)(参数列表) =^返回值类型(参数列表){表达式};  其中返回值和参数列表可以神略 ,最简单的block是  ^{xxxx}; voi ...

  4. The Automated Testing Handbook 自动化测试手册简介

    Learn what works, what doesn't and why. The Automated Testing Handbook is a practical blueprint for ...

  5. Fitnesse+RestFixture:Web服务回归测试利器

    RestFixture是Fitness的一个测试REST服务的插件,用于调用标准的http GET/POST等请求方法,并可以用XPath语法和Javascript语法检验http响应.本文介绍安装运 ...

  6. cadence异型孔

    1:画route path的边框,画在board geometry的ncroute_path层上,可以用zcopy (暂时没用过)      没有的话可能:WARNING: No route path ...

  7. 修改Zabbix默认运行账户

    默认Zabbix运行的账户是Zabbix,但在自动部署的时候,Agent与Server的先后顺序不定,而且官方不建议两者使用同一个账户.   所以,解压压缩包后,进入目录: vi configure ...

  8. BBED的安装

    BBED是Block Browser EDitor的缩写,只有linux/unix版本,没有windows版本. 11g中默认是不带bbed的,如果要使用,可以在10g中拷贝过来,然后再进行编译使用. ...

  9. CentOS7 mariadb 修改编码

    CentOS7 mariadb 编码的修改: 网上看了不少的解决方案,要么是比较老的,要么是不正确,测试成功的方式,记录备查. 登录MySQL,使用SHOW VARIABLES LIKE 'chara ...

  10. 【转】Yahoo!团队:网站性能优化的35条黄金守则

    Yahoo!的 Exceptional Performance团队为改善 Web性能带来最佳实践.他们为此进行了一系列的实验.开发了各种工具.写了大量的文章和博客并在各种会议上参与探讨.最佳实践的核心 ...