func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 2e5 + 100, inF = 1e6 + 10;   int n, k, u, v, c, maxi, a[N], sz[N];   bool ok;   vector<int> nei[N];   int get_sz(int v, int par = -1) {     for (int u : nei[v])       if (u != par) sz[v] += get_sz(u, v);     return ++sz[v];   }   int dfs(int v, int par = -1) {     int dp = (a[v] < c ? -inF : 1);     int mx1 = 0, mx2 = 0;     for (int u : nei[v])       if (u != par) {         int DP = dfs(u, v);         if (DP == sz[u])           dp += DP;         else {           mx2 = max(mx2, DP);           if (mx2 > mx1) swap(mx1, mx2);         }       }     ok |= (dp + mx1 + mx2) >= k;     if (a[v] < c) return 0;     return dp + mx1;   }   bool check() {     ok = false;     dfs(min_element(a, a + n) - a);     return ok;   }   int main() {     ios::sync_with_stdio(false), cin.tie(0);     cin >> n >> k;     for (int i = 0; i < n; i++) cin >> a[i];     for (int i = 0; i < n - 1; i++) {       cin >> u >> v;       nei[--u].push_back(--v);       nei[v].push_back(u);     }     get_sz(min_element(a, a + n) - a);     int l = 0, r = inF;     while (r - l > 1) {       c = (l + r) >> 1;       if (check())         l = c;       else         r = c;     }     cout << l;     return 0;   }   