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;
#define int long long
#define inf 0x3F3F3F3F3F3F3F3F
const int MXN = 1e5 + 5;
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, k, t;
cin >> n >> k >> t;
k--;
int x[n];
for (int &i : x) cin >> i;
int l = 0, r = inf;
while (l < r)
{
int mid = (l + r) >> 1;
int L = k - 1, R = k + 1;
int cnt = 1;
while (1)
{
if (L >= 0 && (R >= n || x[k] - x[L] <= x[R] - x[k]))
{
if ((x[R - 1] - x[L] + mid * 2 - 1) / (mid * 2) > cnt * t) break;
L--;
cnt++;
}
else if (R < n && (L < 0 || x[k] - x[L] >= x[R] - x[k]))
{
if ((x[R] - x[L + 1] + mid * 2 - 1) / (mid * 2) > cnt * t) break;
R++;
cnt++;
}
else break;
}
if (cnt == n) r = mid;
else l = mid + 1;
}
cout << l << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |