Hihocoder Challenge 14 Topic 1: Inequalities

Source: Internet
Author: User

Topic 1: Inequality time limit:10000msSingle Point time limit:1000msMemory Limit:256MBDescribe

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

Output

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

Sample input
4X = 1X = 2X = 3X > 0
Sample output
2

This question does not say that C is an integer, but the commit code to the C as an integer can be AC, Solution: Enumeration x= -0.5,0,0.5, ... 1000.5 Check the number of inequalities that satisfy the condition, ans is the maximum value
#include <cstdio>#include<cstring>#include<string>#include<map>using namespacestd;Chars[Ten];Charst[Ten];intN;inta[2020];intMain () {scanf ("%d",&N); intx;  for(intI=0; i<n;i++) {scanf ("%s", s); scanf ("%s", s); scanf ("%s", ST); SSCANF (St,"%d",&x); if(strcmp (s),"=")==0) {a[2* (x+1)]++; }        Else if(strcmp (s),">")==0){             for(intj=2* (x+1)+1;j< .; j + +) A[j]++; }Else if(strcmp (s),">=")==0){             for(intj=2* (x+1);j< .; j + +) A[j]++; }Else if(strcmp (s),"<")==0){             for(intj=2*x+1; j>=0; j--) A[j]++; }Else if(strcmp (s),"<=")==0){             for(intj=2* (x+1); j>=0; j--) A[j]++; }    }    intAns =0;  for(intI=0;i< .; i++){        if(Ans<a[i]) ans =A[i]; } printf ("%d\n", ans); return 0;}



Hihocoder Challenge 14 Topic 1: Inequalities

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.