#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> bool maximize(T &a, const T &b){ return (a < b ? a = b, 1 : 0); }
template<class T> bool minimize(T &a, const T &b){ return (a > b ? a = b, 1 : 0); }
#define fi first
#define se second
#define pb push_back
#define ii pair<int, int>
#define all(x) x.begin(), x.end()
#define TASK "nonsense"
/// end of template ///
const int N = 2e3 + 23;
int n,p,q,a[N];
namespace sub1
{
bool check()
{
return (n<=100);
}
const int N = 102;
bool dp[N][N][N];
bool check(int w)
{
memset(dp,0,sizeof(dp));
for (int j=0; j<N; ++j) for (int k=0; k<N; ++k) dp[0][j][k]=1;
for (int i=1; i<=n; ++i)
{
int cmp,cmq;
for (int j=i; j>=1; --j)
{
if (a[i]-a[j]+1<=w) cmp=j;
if (a[i]-a[j]+1<=2*w) cmq=j;
}
for (int j=0; j<=n; ++j) for (int k=0; k<=n; ++k)
{
bool &cur=dp[i][j][k];
if (j)
{
cur|=dp[cmp-1][j-1][k];
}
if (k)
{
cur|=dp[cmq-1][j][k-1];
}
}
}
return dp[n][min(n,p)][min(n,q)];
}
void solve()
{
int lo=1,hi=1e9,mid,ans;
while (lo<=hi)
{
mid=(lo+hi)>>1;
if (check(mid)) ans=mid,hi=mid-1;
else lo=mid+1;
}
cout<<ans;
}
}
void solve()
{
cin>>n>>p>>q;
for (int i=1; i<=n; ++i) cin>>a[i];
sort(a+1,a+1+n);
if (sub1::check()) return void(sub1::solve());
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
// freopen(TASK".inp","r",stdin);
// freopen(TASK".out","w",stdout);
int testcase=1;
// cin>>testcase;
while (testcase--)
solve();
// #define TIME (1.0 * clock() / CLOCKS_PER_SEC)
// cerr << "Time elapsed: " << TIME << " s.\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |