#include <bits/stdc++.h>
using namespace std;
int dp[2005][2005], a[2005];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, p, q, l=1, r=1e9;
cin >> n >> p >> q;
p=min(p, n);
for (int i=1; i<=n; i++)
cin >> a[i];
sort(a+1, a+n+1);
while (l<r)
{
int mid=(l+r)/2;
for (int i=1; i<=n; i++)
{
int x=upper_bound(a+1, a+n+1, a[i]-mid)-a-1, y=upper_bound(a+1, a+n+1, a[i]-mid*2)-a-1;
for (int j=0; j<=i; j++)
{
dp[i][j]=dp[y][j]+1;
if (j)
dp[i][j]=min(dp[i][j], dp[x][j-1]);
}
}
if (dp[n][p]>q)
l=mid+1;
else
r=mid;
}
cout << l;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
724 KB |
Output is correct |
2 |
Correct |
1 ms |
328 KB |
Output is correct |
3 |
Correct |
1 ms |
328 KB |
Output is correct |
4 |
Correct |
1 ms |
724 KB |
Output is correct |
5 |
Correct |
1 ms |
724 KB |
Output is correct |
6 |
Correct |
1 ms |
724 KB |
Output is correct |
7 |
Correct |
1 ms |
724 KB |
Output is correct |
8 |
Correct |
1 ms |
708 KB |
Output is correct |
9 |
Correct |
1 ms |
712 KB |
Output is correct |
10 |
Correct |
1 ms |
724 KB |
Output is correct |
11 |
Correct |
1 ms |
724 KB |
Output is correct |
12 |
Correct |
1 ms |
724 KB |
Output is correct |
13 |
Correct |
1 ms |
724 KB |
Output is correct |
14 |
Correct |
1 ms |
724 KB |
Output is correct |
15 |
Correct |
1 ms |
724 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
99 ms |
14164 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
3 |
Correct |
95 ms |
14164 KB |
Output is correct |
4 |
Correct |
92 ms |
14164 KB |
Output is correct |
5 |
Correct |
90 ms |
14152 KB |
Output is correct |
6 |
Correct |
96 ms |
14284 KB |
Output is correct |
7 |
Correct |
93 ms |
14152 KB |
Output is correct |
8 |
Correct |
94 ms |
14156 KB |
Output is correct |
9 |
Correct |
95 ms |
14164 KB |
Output is correct |
10 |
Correct |
94 ms |
14164 KB |
Output is correct |
11 |
Correct |
94 ms |
14284 KB |
Output is correct |
12 |
Correct |
95 ms |
14164 KB |
Output is correct |
13 |
Correct |
94 ms |
14128 KB |
Output is correct |
14 |
Correct |
94 ms |
14164 KB |
Output is correct |
15 |
Correct |
94 ms |
14164 KB |
Output is correct |