hihocoder #1223 : 不等式 水题
#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
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 : 不等式 水题的更多相关文章
- [hihoCoder]1014 Trie水题
最最最最最最最基本的Trie词频统计应用了. package trie; import java.util.Scanner; public class Main { public static voi ...
- hihocoder 1322 - 树结构判定 - [hiho一下161周][模板题/水题]
题目链接:http://hihocoder.com/problemset/problem/1322 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 给定一个包含 N 个顶 ...
- HDU 4950 Monster (水题)
Monster 题目链接: http://acm.hust.edu.cn/vjudge/contest/123554#problem/I Description Teacher Mai has a k ...
- POJ 水题(刷题)进阶
转载请注明出处:優YoU http://blog.csdn.net/lyy289065406/article/details/6642573 部分解题报告添加新内容,除了原有的"大致题意&q ...
- ACM_一道耗时间的水题
一道耗时间的水题 Time Limit: 2000/1000ms (Java/Others) Problem Description: Do you know how to read the phon ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- ACM :漫漫上学路 -DP -水题
CSU 1772 漫漫上学路 Time Limit: 1000MS Memory Limit: 131072KB 64bit IO Format: %lld & %llu Submit ...
- ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)
1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 154 Solved: 112[ ...
- [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 ...
随机推荐
- 【转】Windows环境下Android Studio v1.0安装教程
原文网址:http://ask.android-studio.org/?/article/9 http://android-studio.org/index.php/docs/experience/1 ...
- ioctl用法详解 (网络)
本函数影响由fd参数引用的一个打开的文件. #include#include int ioctl( int fd, int request, .../* void *arg */ );返回0:成功 ...
- Linux 中直接 I/O 机制的介绍
https://www.ibm.com/developerworks/cn/linux/l-cn-directio/ 对于传统的操作系统来说,普通的 I/O 操作一般会被内核缓存,这种 I/O 被称作 ...
- MYSQL内存
全局内存(BASE MEMORY) 线程内存(MEMORY PER CONNECTION) max_conecctions:整个 MySQL 允许的最大连接数; max_user_connection ...
- Android下载速度计算
long startTime = System.currentTimeMillis(); // 开始下载时获取开始时间 long curTime = System.currentTimeMillis( ...
- cocos2d-x 添加背景音乐和音效-SimpleAudioEngine
首先,要想使用音效,需要启用音效引擎库CocosDenshion中的SimpleAudioEngine类, #include "SimpleAudioEngine.h" Cocos ...
- 【转】javascript-图片预加载技术
1,脚本代码: /** * 图片头数据加载就绪事件 - 更快获取图片尺寸 * @version 2011.05.27 * @author TangBin * @see http://www.plane ...
- Python 变量 对象 引用
1.变量 变量第一次赋值时被创建,变量在使用前必须赋值 变量本身没有类型,变量类型为它引用的对象类型: 变量在使用时被替换成它引用的对象 2.对象 对象本身具有计数和类型,变量引用对象,当对象的引用变 ...
- mybatis系列-09-订单商品数据模型
9.1 数据模型分析思路 1.每张表记录的数据内容 分模块对每张表记录的内容进行熟悉,相当 于你学习系统 需求(功能)的过程. 2.每张表重要的字段设置 非空字段.外键字段 3.数据库级别表与 ...
- 【转】Maven实战(一)---Maven Build--缺少Jar包
原博文出于: http://blog.csdn.net/liutengteng130/article/details/41426955 感谢! 新建的Maven项目,在build的时候总是打包失败 ...