1 #include <bits/stdc++.h> 2 using namespace std; 3 4 int st[100000][17]; 5 int meow[100000]; 6 int n; 7 8 void st_init(){ 9 int jmax = floor(log(n)/log(2)); 10 for (int i = 0; i < n; i++) 11 st[i][0] = meow[i]; 12 for (int j = 1; j <= jmax; j++) 13 for (int i = 0; i < n; i++) 14 if (i + (1 << j) - 1 <= n) 15 st[i][j] = min(st[i][j - 1], st[i + (1 << (j - 1))][j - 1]); 16 } 17 18 int st_query(int n, int m){ 19 int k = floor(log(m - n + 1) / log(2)); 20 return min(st[n][k], st[m - (1 << k) + 1][k]); 21 } 22 23 int main(){ 24 n = 5; 25 for (int i = 0; i < n; i++) 26 cin >> meow[i]; 27 st_init(); 28 cout << st_query(0, n - 1); 29 return 0; 30 }