#include<bits/stdc++.h>
using namespace std;
const long long mod=998244353;
long long n,a,b,sum,c[2003],dp[2050][2050];
int f(int x,int y,int z)
{
if(y>a)return 1e18;
if(x==n)return 0;
if(dp[x][y]!=-1)return dp[x][y];
int mx=1e18;
for(int i=x;i<n;i++)
{
for(int j=i;j<n;j++)
{
if(c[i]-c[x]+1>z*2)break;
if(c[i]-c[x]+1<=z)mx=min(mx,f(i+1,y+1,z));
else mx=min(mx,f(i+1,y,z)+1);
}
}
return dp[x][y]=mx;
}
bool ck(int x)
{
int as=0,bs=0;
memset(dp,-1,sizeof dp);
if(f(0,0,x)<=b)return 1;
else return 0;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
cin>>n>>a>>b;
for(int i=0;i<n;i++)cin>>c[i];
int l=1,r=1e9+1,mid;
while(l<r)
{
mid=(l+r)/2;
if(ck(mid))r=mid;
else l=mid+1;
}
cout<<l;
}
Compilation message
watching.cpp: In function 'int f(int, int, int)':
watching.cpp:7:19: warning: overflow in implicit constant conversion [-Woverflow]
if(y>a)return 1e18;
^~~~
watching.cpp:10:12: warning: overflow in implicit constant conversion [-Woverflow]
int mx=1e18;
^~~~
watching.cpp: In function 'bool ck(int)':
watching.cpp:24:9: warning: unused variable 'as' [-Wunused-variable]
int as=0,bs=0;
^~
watching.cpp:24:14: warning: unused variable 'bs' [-Wunused-variable]
int as=0,bs=0;
^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
167 ms |
33272 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1080 ms |
33312 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |