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 ...
随机推荐
- equals(),hashcode()方法详解
Java中的equals方法和hashCode方法是Object中的,所以每个对象都是有这两个方法的,有时候我们需要实现特定需求,可能要重写这两个方法,今天就来介绍一些这两个方法的作用. equals ...
- qqmap 的一些操作
; var mapcontorl = "mapContainer"; var fullscreen = false; function qqMap(options) { var t ...
- [LeetCode] Single Number III ( a New Questions Added today)
Given an array of numbers nums, in which exactly two elements appear only once and all the other ele ...
- 坚持自学的第二天,bootstrap初入门
前言 昨天,初步学完了jekyll目录结构与Liquid语法的应用与认识. 日志 今天刚入门,做了一个bootstrap导航栏,但是选中状态不行,找了JS中写好的API,写法与视频中讲的有点不一样,但 ...
- 转-CMMI在中国之混乱-CMMI比ISO9000会更惨
CMMI在中国之混乱-CMMI比ISO9000会更惨 自己接触CMM/CMMI已经有8年时间了,现在静心回顾一下,觉得CMMI在中国的命运会比ISO9000还悲惨. 一组现象或许让你我对此结论有更深入 ...
- Multiple reportviewers on one page With reportviwer 11.0
Hi, evreryone: When I use VS 2012 to create report with reportviwer 11.0, I meet a problem abou ...
- libvirt虚拟系统如何增加usb设备
之前干这些事情都是通过virt-manager来搞定的.不过由于这个图形界面不太方便,而且现在没法打开(具体原因不详,每次打开提示一些方法未实现什么的),所以试下用libvirt的命令virsh来搞定 ...
- HTTP响应报文与工作原理详解
超文本传输协议(Hypertext Transfer Protocol,简称HTTP)是应用层协议.HTTP 是一种请求/响应式的协议,即一个客户端与服务器建立连接后,向服务器发送一个请求;服务器接到 ...
- homework-07
终于等到了一次难度相对比较小的问题,只要读完提问题就好,但又不得不说自己真的很菜,且不说C++掌握的不好,连英文也比较差,导致读的非常吃力,不过我还是坚持读完了四篇英文文章,大致意思是可以了解的,但是 ...
- 最大连续子数和问题-homework-03
一.说明 这次的作业做的不好,一小点怨念ing····· 首先向TA说明下,我的小伙伴“丢下”我后我不知道,以至于发现剩下我一个的时间有点晚,我机智地找到了一个3个人的小组,又叫到了一个小伙伴,但是悲 ...