#include #include #include using namespace std; struct Bod { double hodnota; int typ; bool operator<(const Bod &b) const { return (hodnota < b.hodnota || (hodnota == b.hodnota && typ < b.typ)); } }; int n; double hodnoty[100100]; Bod udalosti[200200]; int pocet; int main(void) { scanf("%d", &n); for (int i=0; i hodnoty[i-1] && hodnoty[i] > hodnoty[i+1]) { udalosti[pocet++] = (Bod){hodnoty[i], 1}; udalosti[pocet++] = (Bod){hodnoty[i], 3}; } // minimum else if (hodnoty[i] < hodnoty[i-1] && hodnoty[i] < hodnoty[i+1]) { udalosti[pocet++] = (Bod){hodnoty[i], 2}; udalosti[pocet++] = (Bod){hodnoty[i], 4}; } } sort(udalosti, udalosti + pocet); // zpracování událostí int max = 0; double h = 0.0; int pruseciky = 0; for (int i=0; i max) { max = pruseciky; h = (i>0)?((udalosti[i].hodnota + udalosti[i-1].hodnota)/2):(udalosti[i].hodnota); } switch(udalosti[i].typ) { case 1: pruseciky--; break; case 2: pruseciky++; break; case 3: pruseciky--; break; case 4: pruseciky++; break; } } printf("Procenta %lf%%, pocet pruseciku %d\n", h, max); } return 0; }