#include #include #include #include #include using namespace std; unsigned long N; pair hodnoty[100000]; unsigned long long findmin(bool gt, unsigned long long L) { map > mapa; mapa.clear(); int indexposledniho = 0; int pocet = 0; for(int i = 0;i L && hodnoty[indexposledniho].first < hodnoty[i].first - L) { mapa[hodnoty[indexposledniho].second]--; if(mapa[hodnoty[indexposledniho].second] == 0) mapa.erase(mapa.find(hodnoty[indexposledniho].second)); indexposledniho++; } unsigned long minimum; if(mapa.size() > 0) { minimum = (*(--mapa.end())).first; } else { minimum = ULONG_MAX; } mapa[hodnoty[i].second]++; if(i - indexposledniho == 0) continue; if(gt) { if(hodnoty[i].second > minimum) pocet++; } else { if(hodnoty[i].second < minimum) pocet++; } } return pocet; } unsigned long long findmax(bool gt, unsigned long long L) { map > mapa; mapa.clear(); int indexposledniho = 0; int pocet = 0; for(int i = 0;i L && hodnoty[indexposledniho].first < hodnoty[i].first - L) { mapa[hodnoty[indexposledniho].second]--; if(mapa[hodnoty[indexposledniho].second] == 0) mapa.erase(mapa.find(hodnoty[indexposledniho].second)); indexposledniho++; } unsigned long minimum; if(mapa.size() > 0) { minimum = (*(--mapa.end())).first; } else { minimum = 0; } mapa[hodnoty[i].second]++; if(i - indexposledniho == 0) continue; if(gt) { if(hodnoty[i].second > minimum) pocet++; } else { if(hodnoty[i].second < minimum) 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