Submission #1294934

#TimeUsernameProblemLanguageResultExecution timeMemory
1294934BahaminSparklers (JOI17_sparklers)C++20
50 / 100
171 ms327680 KiB
#include <bits/stdc++.h> using namespace std; template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; } #define ll long long #define ld long double #define all(a) (a).begin(), (a).end() #define sui cout.tie(NULL); cin.tie(NULL); ios_base::sync_with_stdio(false) const int MAX_N = 1e5 + 5; const int MOD = 1e9 + 7; const ll INF = 1e9; const ld EPS = 1e-9; const int LOG = 30; int n, k, t; int a[MAX_N]; bool check(int s) { bool dp[n + 1][n + 1]; dp[k][k] = true; for (int i = k; i >= 0; i--) { for (int j = (i == k ? k + 1 : k); j < n; j++) { dp[i][j] = false; if (a[j] - a[i] <= 1ll * (j - i) * s * t * 2) dp[i][j] = (i < k ? dp[i + 1][j] : false) || (j > k ? dp[i][j - 1] : false); } } return dp[0][n - 1]; } void solve() { cin >> n >> k >> t; k--; for (int i = 0; i < n; i++) cin >> a[i]; int l = -1; int r = 1e9; while (r - l > 1) { int mid = (r + l) >> 1; if (check(mid)) r = mid; else l = mid; } cout << r << "\n"; } int main() { sui; int tc = 1; //cin >> tc; for (int t = 1; t <= tc; t++) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...