Submission #955808

#TimeUsernameProblemLanguageResultExecution timeMemory
955808vjudge1Sparklers (JOI17_sparklers)C++17
50 / 100
150 ms262144 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(0); cin.tie(0); ll n, k, t, i, j, a, lo = 1, hi = (1 << 30), s; cin >> n >> k >> t; k--; vector<ll> v(n); for (i = 0; i < n; i++) cin >> v[i]; if (!v[n - 1]) { cout << 0; return 0; } vector<vector<bool> > dp(n); queue<vector<ll> > q; for (i = 0; i < n; i++) dp[i].resize(i + 1); while (hi - lo > 1) { s = (hi + lo) / 2; for (i = 0; i < n; i++) { for (j = 0; j <= i; j++) dp[i][j] = 0; } dp[k][k] = 1; q.push({k, k}); while (!q.empty()) { i = q.front()[0]; j = q.front()[1]; q.pop(); a = 2 * t * s * (i - j + 1); if (j && !dp[i][j - 1] && v[i] - v[j - 1] <= a) { dp[i][j - 1] = 1; q.push({i, j - 1}); } if (i < n - 1 && !dp[i + 1][j] && v[i + 1] - v[j] <= a) { dp[i + 1][j] = 1; q.push({i + 1, j}); } } if (dp[n - 1][0]) hi = s; else lo = s; } cout << hi; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...