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&&I==X) cnt++; + Else if(fg==-1&&I<X) cnt++; A Else if(fg==1&&I>X) cnt++; the Else if(fg==-2&&I<=X) cnt++; + Else if(fg==2&&I>=X) cnt++; - } $ans=Max (ans,cnt); $ } -cout<<ans<<Endl; -}
hihocoder-1223-Inequalities