This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
const int oo = 1e9 + 7;
int dp [N][N][N];
int n;
int a[N];
int go (int i, int s, int l) {
if (i == n) return 0;
auto &rf = dp[i][s][l];
if (rf != -1) return rf;
rf = oo;
for (int j = i; j < n; ++j) {
if (s)
rf = min(rf, max(go(j + 1, s - 1, l), a[j] - a[i] + 1));
if (l)
rf = min(rf, max(go(j + 1, s, l - 1), (a[j] - a[i] + 2) / 2));
}
return rf;
}
int main() {
int p, q; cin >> n >> p >> q;
for (int i = 0; i < n; ++i) cin >> a[i];
sort (a, a + n);
memset(dp, -1, sizeof dp);
cout << go (0, p, q) << '\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |