Submission #551049

#TimeUsernameProblemLanguageResultExecution timeMemory
551049LucaDantasSparklers (JOI17_sparklers)C++17
50 / 100
50 ms4416 KiB
#include <bits/stdc++.h> using namespace std; constexpr int maxn = 1010, inf = 0x3f3f3f3f; int x[maxn], n, k, T, v; int dp[maxn][maxn]; void solve(int l, int r) { if(dp[l][r]) return; dp[l][r] = 1; if(l && (x[r] - x[l-1]) <= 1ll * 2 * v * T * (r-l+1)) solve(l-1, r); if(r < n-1 && (x[r+1] - x[l]) <= 1ll * 2 * v * T * (r-l+1)) solve(l, r+1); } int main() { scanf("%d %d %d", &n, &k, &T); --k; // 0-indexed for(int i = 0; i < n; i++) scanf("%d", x+i); int l = 0, r = inf, ans = -1; while(l <= r) { int m = (l+r) >> 1; v = m; memset(dp, 0, sizeof dp); solve(k, k); if(dp[0][n-1]) r = m-1, ans = m; else l = m+1; } printf("%d\n", ans); }

Compilation message (stderr)

sparklers.cpp: In function 'int main()':
sparklers.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     scanf("%d %d %d", &n, &k, &T); --k; // 0-indexed
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sparklers.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         scanf("%d", x+i);
      |         ~~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...