이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |