# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1092082 | 2024-09-23T05:38:08 Z | thangdz2k7 | Sparklers (JOI17_sparklers) | C++17 | 21 ms | 2992 KB |
// author : thembululquaUwU // 3.9.2024 #include <bits/stdc++.h> #define pb push_back #define fi first #define se second #define endl '\n' using namespace std; using ll = long long; using ii = pair <int, int>; using vi = vector <int>; const int N = 1e5 + 5; const int mod = 1e9 + 7; void maxl(auto &a, auto b) {a = max(a, b);} void minl(auto &a, auto b) {a = min(a, b);} int n, k; ll t, x[N], b[N]; bool check(int s){ for (int i = 1; i <= n; ++ i) b[i] = x[i] - t * i * s * 2; int bl = k, br = k; for (int i = 1; i <= k; ++ i) if (b[i] > b[bl]) bl = i; for (int i = k; i <= n; ++ i) if (b[i] < b[br]) br = i; int l = k, r = k; ll vmax = b[k], vmin = b[k]; while (bl <= l || r <= br){ int ol = l, ork = r; for (; l >= bl && b[l] >= vmin; -- l) maxl(vmax, b[l]); for (; r <= br && b[r] <= vmax; ++ r) minl(vmin, b[r]); if (l == ol && r == ork) return false; } l = 1, r = n; vmax = b[l], vmin = b[r]; while (l <= bl || r >= br){ int ol = l, ork = r; for (; l <= bl && b[l] >= vmin; ++ l) maxl(vmax, b[l]); for (; r >= br && b[r] <= vmax; -- r) minl(vmin, b[r]); if (l == ol && r == ork) return false; } return true; } void solve(){ cin >> n >> k >> t; for (int i = 1; i <= n; ++ i) cin >> x[i]; int lo = 0, hi = x[n] / t + 1, ans = hi; while (lo <= hi){ int mid = lo + hi >> 1; if (check(mid)) ans = mid, hi = mid - 1; else lo = mid + 1; } cout << ans; } int main(){ if (fopen("pqh.inp", "r")){ freopen("pqh.inp", "r", stdin); freopen("pqh.out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; // cin >> t; while (t --) solve(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 416 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 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 | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 464 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 344 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
19 | Correct | 1 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 | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 416 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 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 | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 464 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 344 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
19 | Correct | 1 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 | 0 ms | 344 KB | Output is correct |
23 | Correct | 0 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 348 KB | Output is correct |
25 | Correct | 0 ms | 348 KB | Output is correct |
26 | Correct | 0 ms | 348 KB | Output is correct |
27 | Correct | 0 ms | 472 KB | Output is correct |
28 | Correct | 1 ms | 348 KB | Output is correct |
29 | Correct | 0 ms | 348 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 1 ms | 348 KB | Output is correct |
32 | Correct | 1 ms | 412 KB | Output is correct |
33 | Correct | 0 ms | 348 KB | Output is correct |
34 | Correct | 1 ms | 348 KB | Output is correct |
35 | Correct | 0 ms | 348 KB | Output is correct |
36 | Correct | 0 ms | 472 KB | Output is correct |
37 | Correct | 0 ms | 348 KB | Output is correct |
38 | Correct | 0 ms | 348 KB | Output is correct |
39 | Correct | 1 ms | 348 KB | Output is correct |
40 | Correct | 1 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 416 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 0 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 | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 464 KB | Output is correct |
12 | Correct | 0 ms | 348 KB | Output is correct |
13 | Correct | 1 ms | 344 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 0 ms | 348 KB | Output is correct |
17 | Correct | 1 ms | 348 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
19 | Correct | 1 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 | 0 ms | 344 KB | Output is correct |
23 | Correct | 0 ms | 348 KB | Output is correct |
24 | Correct | 1 ms | 348 KB | Output is correct |
25 | Correct | 0 ms | 348 KB | Output is correct |
26 | Correct | 0 ms | 348 KB | Output is correct |
27 | Correct | 0 ms | 472 KB | Output is correct |
28 | Correct | 1 ms | 348 KB | Output is correct |
29 | Correct | 0 ms | 348 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 1 ms | 348 KB | Output is correct |
32 | Correct | 1 ms | 412 KB | Output is correct |
33 | Correct | 0 ms | 348 KB | Output is correct |
34 | Correct | 1 ms | 348 KB | Output is correct |
35 | Correct | 0 ms | 348 KB | Output is correct |
36 | Correct | 0 ms | 472 KB | Output is correct |
37 | Correct | 0 ms | 348 KB | Output is correct |
38 | Correct | 0 ms | 348 KB | Output is correct |
39 | Correct | 1 ms | 348 KB | Output is correct |
40 | Correct | 1 ms | 348 KB | Output is correct |
41 | Correct | 12 ms | 2136 KB | Output is correct |
42 | Correct | 1 ms | 348 KB | Output is correct |
43 | Correct | 3 ms | 788 KB | Output is correct |
44 | Correct | 18 ms | 2908 KB | Output is correct |
45 | Correct | 20 ms | 2916 KB | Output is correct |
46 | Correct | 18 ms | 2904 KB | Output is correct |
47 | Correct | 18 ms | 2908 KB | Output is correct |
48 | Correct | 18 ms | 2908 KB | Output is correct |
49 | Correct | 18 ms | 2824 KB | Output is correct |
50 | Correct | 18 ms | 2908 KB | Output is correct |
51 | Correct | 19 ms | 2908 KB | Output is correct |
52 | Correct | 18 ms | 2992 KB | Output is correct |
53 | Correct | 19 ms | 2780 KB | Output is correct |
54 | Correct | 21 ms | 2904 KB | Output is correct |
55 | Correct | 18 ms | 2876 KB | Output is correct |
56 | Correct | 19 ms | 2908 KB | Output is correct |
57 | Correct | 21 ms | 2984 KB | Output is correct |
58 | Correct | 20 ms | 2928 KB | Output is correct |
59 | Correct | 5 ms | 2140 KB | Output is correct |
60 | Correct | 18 ms | 2744 KB | Output is correct |
61 | Correct | 17 ms | 2652 KB | Output is correct |
62 | Correct | 18 ms | 2900 KB | Output is correct |
63 | Correct | 18 ms | 2908 KB | Output is correct |
64 | Correct | 18 ms | 2908 KB | Output is correct |
65 | Correct | 17 ms | 2968 KB | Output is correct |
66 | Correct | 18 ms | 2908 KB | Output is correct |
67 | Correct | 19 ms | 2908 KB | Output is correct |
68 | Correct | 19 ms | 2908 KB | Output is correct |
69 | Correct | 17 ms | 2760 KB | Output is correct |