Hihocoder #1223: An inequality water problem

Source: Internet
Author: User

#1223: Inequalities

Time Limit:1 Sec

Memory limit:256 MB

Topic Connection http://hihocoder.com/problemset/problem/1223
Description

Given n an inequality about X, the maximum number of questions is set.

Each inequality is one of the following forms:

X < C

X <= C

X = C

X > C

X >= C

Input

The first line is an integer n.

The following n rows, one inequality per line.

Data range:

1<=n<=50,0<=c<=1000

OutputAn integer line that represents the maximum number of inequalities that can be set at the same time. Sample Input

4
X = 1
X = 2
X = 3
X > 0

Sample Output2


HINT

Test instructions

Exercises

Enumerate each number directly, for each number, determine how much data is satisfied

Of course, the data range is larger than the problem, then you have to discretization and update the interval, the last query maximum value is good

Overall, the idea is the same.

Code:

//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>typedefLong Longll;using namespacestd;//freopen ("d.in", "R", stdin);//freopen ("D.out", "w", stdout);#defineSspeed ios_base::sync_with_stdio (0); Cin.tie (0)#defineMAXN 1200051#defineMoD 10007#defineEPS 1e-9intNum;//const int INF=0X7FFFFFFF; //нчоч╢сConst intinf=~0u>>1; inline ll read () {ll x=0, f=1;CharCh=GetChar ();  while(ch<'0'|| Ch>'9'){if(ch=='-') f=-1; ch=GetChar ();}  while(ch>='0'&&ch<='9') {x=x*Ten+ch-'0'; ch=GetChar ();} returnx*F;}//**************************************************************************************stringstr[ -],x;intnum[ -];intMain () {intn=read ();  for(intI=1; i<=n;i++) {cin>>X>>str[i]>>Num[i]; Num[i]*=2; }    intans=0;  for(inti=-2; i<=2002; i++)    {        intTMP =0;  for(intj=1; j<=n;j++)        {            intOK =1; if(str[j]=="<")                if(i>=num[j]) OK=0; if(str[j]=="<=")                if(i>num[j]) OK=0; if(str[j]=="=")                if(i!=num[j]) OK=0; if(str[j]==">")                if(i<=num[j]) OK=0; if(str[j]==">=")                if(i<num[j]) OK=0; if(OK) TMP++; } ans=Max (Tmp,ans); } printf ("%d\n", ans);}

Hihocoder #1223: An inequality water problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.