Submission #203800

# Submission time Handle Problem Language Result Execution time Memory
203800 2020-02-22T08:01:19 Z EntityIT Sparklers (JOI17_sparklers) C++14
50 / 100
169 ms 262148 KB
#include<bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define sz(x) ( (int)(x).size() )
using LL = long long;

template<class T>
inline bool asMn(T &a, const T &b) { return a > b ? a = b, true : false; }
template<class T>
inline bool asMx(T &a, const T &b) { return a < b ? a = b, true : false; }
mt19937 rng( (uint32_t)chrono::steady_clock::now().time_since_epoch().count() );

int n, k, t;
vector<int> x;

bool check(int s) {
  vector<vector<bool> > f(n, vector<bool>(n, false) );
  f[k][k] = true;
  for (int diff = 0; diff < n; ++diff) {
    for (int i = 0, j = diff; j < n; ++i, ++j) if (f[i][j]) {
      if (i && (x[j] - x[i - 1] + t - 1) / t <= 2LL * s * (j - i + 1) ) f[i - 1][j] = true;
      if (j + 1 < n && (x[j + 1] - x[i] + t - 1) / t <= 2LL * s * (j - i + 1) ) f[i][j + 1] = true;
    }
  }

  return f[0][n - 1];
}

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);

  #ifdef FourLeafClover
  freopen("input", "r", stdin);
  #endif // FourLeafCLover

  cin >> n >> k >> t; --k;
  x.assign(n, 0);
  for (auto &i : x) cin >> i;

  int l = 0, r = x.back();
  while (l < r) {
    int mid = (l + r) >> 1;
    if (check(mid) ) r = mid;
    else l = mid + 1;
  }

  cout << l << '\n';

  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 388 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 388 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 72 ms 632 KB Output is correct
23 Correct 43 ms 376 KB Output is correct
24 Correct 34 ms 504 KB Output is correct
25 Correct 35 ms 576 KB Output is correct
26 Correct 80 ms 580 KB Output is correct
27 Correct 88 ms 580 KB Output is correct
28 Correct 129 ms 580 KB Output is correct
29 Correct 106 ms 580 KB Output is correct
30 Correct 103 ms 584 KB Output is correct
31 Correct 102 ms 584 KB Output is correct
32 Correct 116 ms 580 KB Output is correct
33 Correct 128 ms 580 KB Output is correct
34 Correct 76 ms 576 KB Output is correct
35 Correct 134 ms 604 KB Output is correct
36 Correct 57 ms 652 KB Output is correct
37 Correct 51 ms 580 KB Output is correct
38 Correct 115 ms 580 KB Output is correct
39 Correct 50 ms 584 KB Output is correct
40 Correct 5 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 504 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 388 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 5 ms 376 KB Output is correct
19 Correct 5 ms 376 KB Output is correct
20 Correct 5 ms 376 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 72 ms 632 KB Output is correct
23 Correct 43 ms 376 KB Output is correct
24 Correct 34 ms 504 KB Output is correct
25 Correct 35 ms 576 KB Output is correct
26 Correct 80 ms 580 KB Output is correct
27 Correct 88 ms 580 KB Output is correct
28 Correct 129 ms 580 KB Output is correct
29 Correct 106 ms 580 KB Output is correct
30 Correct 103 ms 584 KB Output is correct
31 Correct 102 ms 584 KB Output is correct
32 Correct 116 ms 580 KB Output is correct
33 Correct 128 ms 580 KB Output is correct
34 Correct 76 ms 576 KB Output is correct
35 Correct 134 ms 604 KB Output is correct
36 Correct 57 ms 652 KB Output is correct
37 Correct 51 ms 580 KB Output is correct
38 Correct 115 ms 580 KB Output is correct
39 Correct 50 ms 584 KB Output is correct
40 Correct 5 ms 380 KB Output is correct
41 Runtime error 169 ms 262148 KB Execution killed with signal 9 (could be triggered by violating memory limits)
42 Halted 0 ms 0 KB -