#include #include #include #include #include typedef struct Sample{ int cas; int hodnota; }SAMPLE; int main() { int N; char condition[3]; char operation[4]; int val; scanf("%d",&N); SAMPLE pole[N]; int cas,hodnota; for (int i = 0; i < N; i++) { scanf("%d %d", &cas, &hodnota); pole[i].hodnota = hodnota; pole[i].cas = cas; } int Y; scanf("%d",&Y); for(int i = 0; i < Y; i++) { scanf("%s %s %d",condition, operation, &val); int result = 0; int fin= 0; for(int j = 0; j < N; j++) {int begin = 0;int flag10 = 0; for(int k = 0; k < j; k++){ if(pole[k].cas >= (pole[j].cas-val)){ begin = k; flag10 = 1; break; } } if(flag10 == 0) continue; int max = 0,min = 100000,avg = 0; int f = 0; for(int k = begin; k < j; k++){ if(strcmp(operation,"min") == 0){ if(pole[k].hodnota < min) min = pole[k].hodnota; result = min; } if(strcmp(operation,"max") == 0){ if(pole[k].hodnota > max) max = pole[k].hodnota; result = max; } if(strcmp(operation,"avg") == 0){ avg += pole[k].hodnota; result = avg; f = 1; } } if(f) result /= (j - begin); if(strcmp(condition,"lt") == 0){ if (pole[j].hodnota < result) fin++; } if(strcmp(condition,"gt") == 0){ if (pole[j].hodnota > result) fin++; } //printf("R %d F %d J %d H %d<\n",result,fin,j,pole[j].hodnota); } printf("%d\n",fin); } return 0; }