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 ...
随机推荐
- php-PHP试题
ylbtech-doc:php-PHP试题 PHP试题 1.A,PHP试题返回顶部 1.{PHP题目}标识符是变量的名称.PHP中的标识符用“$+变量名”来表示.标识符在PHP中遵循下列选项中的那些规 ...
- Gridview LookupEdit gridLookUpEdit z
LookupEdit一般用法: 绑定数据源: lookUpEdit.Properties.ValueMember = 实际要用的字段; ...
- CABasicAnimation(CAKeyframeAnimation)keypath 取值
- keyPath可以使用的key - #define angle2Radian(angle) ((angle)/180.0*M_PI) - transform.rotation.x 围绕x轴翻转 参 ...
- 告别where 1=1 最佳方案分享
已经有2年没有用过where 1=1了,没想到换了家公司后,又让我看到了它.在网络上面搜索了一下,发现没有人提供一个比较好的方案来解决这一问题.很多人说可以让数据库的优化机制去处理,但是,我想对于大部 ...
- 微软控制台带来的PHP控制台输出问题
/** * 测试文件包含方式对跨平台的影响 * 控制台下测试. * 默认的文件编码为 UTF-8 */ function testChinese() { $file = __DIR__ . '/con ...
- 你认为你很了解Javascript?
(翻译不当之处请谅解) 来源:http://www.ido321.com/914.html 这里有5个小脚本,有助于你真正理解JavaScript核心–闭包和作用域.没有在控制台运行之前,尝试回答每个 ...
- 瞬间从IT屌丝变大神——命名规则
为了避免命名冲突,命名规则如下: 公共组件因为高度重用,,命名从简,不要加前缀. 各栏目的相应代码,需加前缀,前缀为工程师姓名拼音的首字母,例如:海子前缀为“hz_”,分隔符为下划线"_&q ...
- 5个让人激动的Java项目
每个Java/JVM领域的技术专家都应从那些项目中获益,他们中有2011在SanJose举办的Jax 会议中提名为最好的技术产品奖的.我之所以选择它们,是因为它们可以广泛用于一系列的项目中,解决真实问 ...
- 第三百零一天 how can i 坚持
其实真搞不大懂自己.不喜欢巴结人,也不喜欢阿谀奉承,但老是感觉自己却又在那么做,是对自己要求太高了,想太多?? 郭娜好像把我拉黑了,拉黑就拉黑吧.或许真不合适. 睡觉.
- C#正则表达式判断字符串是否是金钱
public static bool IsMoney(string input) { string pattern = @"^\-{0,1}[0-9]{0,}\.{0,1}[0-9]{1,} ...