Submission #883182

# Submission time Handle Problem Language Result Execution time Memory
883182 2023-12-04T18:02:34 Z MilosMilutinovic Sparklers (JOI17_sparklers) C++14
50 / 100
209 ms 262144 KB
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k, t;
  cin >> n >> k >> t;
  --k;
  vector<int> x(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  auto Check = [&](long long s) {
    vector<vector<bool>> dp(n, vector<bool>(n));
    vector<vector<bool>> was(n, vector<bool>(n));
    function<bool(int, int)> Solve = [&](int L, int R) {
      if (was[L][R]) {
        return dp[L][R];
      }
      was[L][R] = true;
      if (L == R) {
        if (L == k) {
          dp[L][R] = true;
        } else {
          dp[L][R] = false;
        }
        return dp[L][R];
      }
      long long f = t * 1LL * (R - L);
      if (f <= 5e8) {
        f *= 2;
      }
      if (f <= 1e9) {
        f *= s;
      }      
      if ((x[R] - x[L]) <= f) {
        if (Solve(L + 1, R) || Solve(L, R - 1)) {
          dp[L][R] = true;
        }
      }
      return dp[L][R];
    };
    return Solve(0, n - 1);
  };
  long long low = 0, high = 2e9, ans = 0;
  while (low <= high) {
    long long mid = low + high >> 1;
    if (Check(mid)) {
      ans = mid;
      high = mid - 1;
    } else {
      low = mid + 1;
    }
  }
  cout << ans << '\n';
  return 0;
}

Compilation message

sparklers.cpp: In function 'int main()':
sparklers.cpp:49:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   49 |     long long mid = low + high >> 1;
      |                     ~~~~^~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 500 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 500 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 69 ms 856 KB Output is correct
23 Correct 28 ms 604 KB Output is correct
24 Correct 113 ms 736 KB Output is correct
25 Correct 209 ms 908 KB Output is correct
26 Correct 86 ms 916 KB Output is correct
27 Correct 90 ms 860 KB Output is correct
28 Correct 123 ms 1108 KB Output is correct
29 Correct 89 ms 860 KB Output is correct
30 Correct 95 ms 1064 KB Output is correct
31 Correct 95 ms 916 KB Output is correct
32 Correct 46 ms 860 KB Output is correct
33 Correct 92 ms 860 KB Output is correct
34 Correct 55 ms 860 KB Output is correct
35 Correct 16 ms 860 KB Output is correct
36 Correct 198 ms 860 KB Output is correct
37 Correct 205 ms 924 KB Output is correct
38 Correct 81 ms 860 KB Output is correct
39 Correct 66 ms 860 KB Output is correct
40 Correct 91 ms 1112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 500 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 69 ms 856 KB Output is correct
23 Correct 28 ms 604 KB Output is correct
24 Correct 113 ms 736 KB Output is correct
25 Correct 209 ms 908 KB Output is correct
26 Correct 86 ms 916 KB Output is correct
27 Correct 90 ms 860 KB Output is correct
28 Correct 123 ms 1108 KB Output is correct
29 Correct 89 ms 860 KB Output is correct
30 Correct 95 ms 1064 KB Output is correct
31 Correct 95 ms 916 KB Output is correct
32 Correct 46 ms 860 KB Output is correct
33 Correct 92 ms 860 KB Output is correct
34 Correct 55 ms 860 KB Output is correct
35 Correct 16 ms 860 KB Output is correct
36 Correct 198 ms 860 KB Output is correct
37 Correct 205 ms 924 KB Output is correct
38 Correct 81 ms 860 KB Output is correct
39 Correct 66 ms 860 KB Output is correct
40 Correct 91 ms 1112 KB Output is correct
41 Runtime error 114 ms 262144 KB Execution killed with signal 9
42 Halted 0 ms 0 KB -