#include #include #include #include using namespace std; unsigned long N; pair hodnoty[100000]; unsigned long long findmin(bool gt, unsigned long long L) { int indexposledniho = 0; int pocet = 0; for(int i = 0;i L && hodnoty[indexposledniho].first < hodnoty[i].first - L) { indexposledniho++; } if(i - indexposledniho == 0) continue; unsigned long minimum = ULONG_MAX; for(int j = indexposledniho;j minimum) pocet++; } else { if(hodnoty[i].second < minimum) pocet++; } } return pocet; } unsigned long long findmax(bool gt, unsigned long long L) { int indexposledniho = 0; int pocet = 0; for(int i = 0;i L && hodnoty[indexposledniho].first < hodnoty[i].first - L) { indexposledniho++; } if(i - indexposledniho == 0) continue; unsigned long maximum = 0; for(int j = indexposledniho;j maximum) maximum = hodnoty[j].second; } if(gt) { if(hodnoty[i].second > maximum) pocet++; } else { if(hodnoty[i].second < maximum) pocet++; } } return pocet; } unsigned long long findavg(bool gt, unsigned long long L) { int indexposledniho = 0; int pocet = 0; for(int i = 0;i L && hodnoty[indexposledniho].first < hodnoty[i].first - L) { indexposledniho++; } if(i - indexposledniho == 0) continue; unsigned long long average = 0; for(int j = indexposledniho;j average) pocet++; } else { if(hodnoty[i].second < average) pocet++; } } return pocet; } int main() { char buff[5]; unsigned long long L; while(scanf("%lu", &N) == 1) { unsigned long long vysledek; for(unsigned int i = 0;i