# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
582117 | urd05 | Sparklers (JOI17_sparklers) | C++17 | 9 ms | 4180 KiB |
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;
int n,k,t;
long long arr[100000];
int dp[1000][1000];
long long s;
int ans(int l,int r) {
if (l==0&&r==n-1) {
return 1;
}
if (dp[l][r]!=-1) {
return dp[l][r];
}
int ret=0;
if (l!=0&&(arr[r]-arr[l-1])/s>=2LL*t*(r-l+1)){
ret|=ans(l-1,r);
}
if (r!=n-1&&(arr[r+1]-arr[l])/s>=2LL*t*(r-l+1)) {
ret|=ans(l,r+1);
}
return dp[l][r]=ret;
}
bool isp(long long x) {
s=x;
memset(dp,-1,sizeof(dp));
return ans(k,k);
}
int main(void) {
scanf("%d %d %d",&n,&k,&t);
k--;
for(int i=0;i<n;i++){
scanf("%lld",&arr[i]);
}
long long lo=-1;
long long hi=1e9; //possible
while (lo+1<hi) {
long long mid=(lo+hi)/2;
if (isp(mid)) {
hi=mid;
}
else {
lo=mid;
}
}
printf("%lld",hi);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |