func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1510, INF = 1e9 + 9;   int n, s, m, k, last[N], a[N], dp[N][N];   bool check(int x) {     memset(dp, 0, sizeof dp);     for (int i = 0; i < n; i++) {       int val = 0;       for (int j = last[i]; j <= i; j++) val += a[j] <= x;       for (int j = 1; j <= m; j++)         dp[i + 1][j] = max(dp[i][j], dp[last[i]][j - 1] + val);     }     return k <= dp[n][m];   }   int main() {     ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);     cin >> n >> s >> m >> k;     for (int i = 0; i < n; i++) cin >> a[i];     fill(last, last + n, n + 1);     while (s--) {       int l, r;       cin >> l >> r;       for (int i = --l; i < r; i++) last[i] = min(last[i], l);     }     int l = 0, r = INF;     while (r - l > 1) {       int mid = l + r >> 1;       check(mid) ? r = mid : l = mid;     }     cout << (r == INF ? -1 : r) << endl;   }   