Submission #1225718

#TimeUsernameProblemLanguageResultExecution timeMemory
1225718siewjhSparklers (JOI17_sparklers)C++20
0 / 100
0 ms468 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 100005; const ll inf = 1e18; ll pos[MAXN], T; int N, K; ll cdiv(ll a, ll b){ return (a + b - 1) / b; } bool test(ll v){ int l = K, r = K; while (l != 1 || r != N){ ll ld = pos[r] - pos[l - 1], rd = pos[r + 1] - pos[l], spt = T * (r - l + 1); if (ld < rd){ if (cdiv(ld, 2 * v) > spt) return 0; l--; } else{ if (cdiv(rd, 2 * v) > spt) return 0; r++; } } return 1; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> N >> K >> T; for (int i = 1; i <= N; i++) cin >> pos[i]; pos[0] = -inf; pos[N + 1] = inf; ll lo = 1, hi = 1e9, ans; while (lo <= hi){ ll m = (lo + hi) >> 1; if (test(m)){ ans = m; hi = m - 1; } else lo = m + 1; } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...