Submission #46287

#TimeUsernameProblemLanguageResultExecution timeMemory
46287qoo2p5Sparklers (JOI17_sparklers)C++17
50 / 100
200 ms50356 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int INF = (int) 1e9 + 1e6 + 123; const ll LINF = (ll) 1e18 + 1e9 + 123; #define rep(i, s, t) for (auto i = (s); i < (t); ++(i)) #define per(i, s, t) for (auto i = (s); i >= (t); --(i)) #define sz(x) ((int)(x).size()) #define mp make_pair #define pb push_back bool mini(auto &x, const auto &y) { if (y < x) { x = y; return 1; } return 0; } bool maxi(auto &x, const auto &y) { if (y > x) { x = y; return 1; } return 0; } void run(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); run(); return 0; } const int N = 5005; int n, k; ll t; ll x[N]; bool dp[N][N]; bool check(ll s) { memset(dp, 0, sizeof dp); dp[k][k] = 1; rep(len, 2, n + 1) { rep(l, 0, n) { int r = l + len - 1; if (r >= n) { break; } dp[l][r] = ((dp[l + 1][r] || dp[l][r - 1]) && (x[r] - x[l]) <= 2 * s * (r - l) * t); } } return dp[0][n - 1]; } void run() { cin >> n >> k >> t; k--; rep(i, 0, n) { cin >> x[i]; } ll left = -1; ll right = (x[n - 1] + t) / t; while (right - left > 1) { ll mid = (left + right) / 2; if (check(mid)) { right = mid; } else { left = mid; } } cout << right << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...