hihocoder-1223-Inequalities

Source: Internet
Author: User

Enter n inequalities to find the maximum number of inequalities at the same time, data range n<=50, inequalities to the right of the data [0,1000]

Analysis: This problem has to change the idea to do, the known data not more than 1000, so enumeration 0~1000 within the number, in order to calculate how many inequalities to meet, and then update the answer, that is, a double cycle, 1000*50

However, this question does not say that must be an integer, such as x>2,x<3, if the requirement x must be an integer, then these two inequalities are not at the same time, but this question does not say, so x can be a floating-point number, then the two inequalities can be set up at the same time.

So when we do, we multiply the data one time, which is [0,2000] to do, but with the boundary problem, it becomes [ -2,2002] enumeration.

1#include <iostream>2#include <string>3#include <vector>4 using namespacestd;5 6 intN;7 strings;8 structnode{9     intFG;Ten     intx; OneNodeintfg=0,intx=0): FG (FG), X (x) {} A }; -Vector<node>v; -  the intMain () - { -Cin>>N; -      while(n--){ +         CharC; -Cin>>C; +Cin>>s; A         intx; atCin>>x; -         intFG; -         if(s=="=") fg=0; -         if(s==">") fg=1; -         if(s=="<") fg=-1; -         if(s=="<=") fg=-2; in         if(s==">=") fg=2; -Node No (FG,2*x); to V.push_back (no); +     } -     intans=0; the      for(inti=-2; i<=2002; i++){ *         intCnt=0; $          for(intj=0; J<v.size (); j + +){Panax Notoginseng             intfg=V[J].FG; -             intx=v[j].x; the             if(fg==0&AMP;&AMP;I==X) cnt++; +             Else if(fg==-1&AMP;&AMP;I&LT;X) cnt++; A             Else if(fg==1&AMP;&AMP;I&GT;X) cnt++; the             Else if(fg==-2&AMP;&AMP;I&LT;=X) cnt++; +             Else if(fg==2&AMP;&AMP;I&GT;=X) cnt++; -         } $ans=Max (ans,cnt); $     } -cout<<ans<<Endl; -}

hihocoder-1223-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.