Time limit:10000msSingle Point time limit:1000msMemory Limit:256MB
Describe
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
Test instructions, we give some inequalities, requirements, the number of inequalities that can be satisfied.
Because, X is different from this fixed integer, directly enumerate all 1-1000 and plus 0.5 all the maximum can be, that is, mapped to -1-0.5 0 0.5 1 1.5 ... Equal number, directly add 1, the other segments of the plus 1 can be. Complexity O (n * n);
#define N 2050#define M 100005#define maxn 205#define MOD 1000000000000000007int n,m,num[n];char str[20];int getindex (int X,bool has) {if (have) {return (x + 1) * 2; } else {return (x + 1) * 2-1; }}int Main () {//freopen ("In.txt", "R", stdin); Freopen ("OUT.txt", "w", stdout); while (S (n)!=eof) {fill (num,0); FI (n) {SS (str); SS (str); S (m); if (str[0] = = ' < ') {if (str[1] = = ') {int x = GetIndex (m,true); for (j,0,x+1) {num[j]++; }} else {int x = GetIndex (M,false); for (j,0,x+1) {num[j]++; }}} else if (str[0] = = ' > ') {if (str[1] = = ' = ') {i NT x = GetIndex (m,true); for (int j = x;j<n;j++) num[j]++; } else {int x = GetIndex (M,false); for (int j = x;j<n;j++) num[j]++; }} else if (str[0] = = ') {int x = GetIndex (m,true); num[x]++; }} int ans = 0; FI (N) ans = max (ans,num[i]); printf ("%d\n", ans); }//fclose (stdin); Fclose (stdout); return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Hihocoder Challenge 14 Topic 1: Inequalities