# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1105825 | 2024-10-28T03:14:22 Z | QuocSensei | Global Warming (CEOI18_glo) | C++14 | 169 ms | 11960 KB |
#include <bits/stdc++.h> #define ll long long #define el cout << '\n' using namespace std; const int maxn = 4e5; int n, bitUp[maxn + 10], bitDown[maxn + 10], lis[maxn + 10], ans = 0; vector<ll> v; ll x, a[maxn + 10]; void updateUp(int x, int v) { for (;x <= maxn; x += x&-x) bitUp[x] = max(bitUp[x], v); } int getUp(int x) { int ans = 0; for (;x ; x&=x-1) ans = max(ans, bitUp[x]); return ans; } void updateDown(int x, int v) { for (;x; x&=x-1) bitDown[x] = max(bitDown[x], v); } int getDown(int x) { int ans = 0; for (;x <= maxn; x += x&-x) ans = max(ans, bitDown[x]); return ans; } ll f(ll x) { return lower_bound(v.begin(), v.end(), x) - v.begin() + 1; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("GLO.INP", "r")) { freopen("GLO.INP", "r", stdin); freopen("GLO.OUT", "w", stdout); } cin >> n >> x; for (int i = 1; i <= n; i++) { cin >> a[i]; v.push_back(a[i]); v.push_back(a[i] + x); } sort(v.begin(), v.end()); v.resize(unique(v.begin(), v.end()) - v.begin()); for (int i = n; i >= 1; i--) { int p = getDown(f(a[i]) + 1) + 1; lis[i] = p; updateDown(f(a[i]), p); } for (int i = 1; i <= n; i++) { int p = getUp(f(a[i] + x) - 1) + 1; int u = getUp(f(a[i]) - 1) + 1; ans = max(ans, p + lis[i] - 1); updateUp(f(a[i]), u); } cout << ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2384 KB | Output is correct |
2 | Correct | 1 ms | 2384 KB | Output is correct |
3 | Correct | 1 ms | 2384 KB | Output is correct |
4 | Correct | 1 ms | 2384 KB | Output is correct |
5 | Correct | 1 ms | 2384 KB | Output is correct |
6 | Correct | 1 ms | 2556 KB | Output is correct |
7 | Correct | 1 ms | 2384 KB | Output is correct |
8 | Correct | 1 ms | 2384 KB | Output is correct |
9 | Correct | 1 ms | 2384 KB | Output is correct |
10 | Correct | 1 ms | 2384 KB | Output is correct |
11 | Correct | 1 ms | 2384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2384 KB | Output is correct |
2 | Correct | 1 ms | 2384 KB | Output is correct |
3 | Correct | 1 ms | 2384 KB | Output is correct |
4 | Correct | 1 ms | 2384 KB | Output is correct |
5 | Correct | 1 ms | 2384 KB | Output is correct |
6 | Correct | 1 ms | 2556 KB | Output is correct |
7 | Correct | 1 ms | 2384 KB | Output is correct |
8 | Correct | 1 ms | 2384 KB | Output is correct |
9 | Correct | 1 ms | 2384 KB | Output is correct |
10 | Correct | 1 ms | 2384 KB | Output is correct |
11 | Correct | 1 ms | 2384 KB | Output is correct |
12 | Correct | 1 ms | 2384 KB | Output is correct |
13 | Correct | 1 ms | 2384 KB | Output is correct |
14 | Correct | 1 ms | 2384 KB | Output is correct |
15 | Correct | 1 ms | 2384 KB | Output is correct |
16 | Correct | 1 ms | 2384 KB | Output is correct |
17 | Correct | 1 ms | 2384 KB | Output is correct |
18 | Correct | 1 ms | 2384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2384 KB | Output is correct |
2 | Correct | 1 ms | 2384 KB | Output is correct |
3 | Correct | 1 ms | 2384 KB | Output is correct |
4 | Correct | 1 ms | 2384 KB | Output is correct |
5 | Correct | 1 ms | 2384 KB | Output is correct |
6 | Correct | 1 ms | 2556 KB | Output is correct |
7 | Correct | 1 ms | 2384 KB | Output is correct |
8 | Correct | 1 ms | 2384 KB | Output is correct |
9 | Correct | 1 ms | 2384 KB | Output is correct |
10 | Correct | 1 ms | 2384 KB | Output is correct |
11 | Correct | 1 ms | 2384 KB | Output is correct |
12 | Correct | 1 ms | 2384 KB | Output is correct |
13 | Correct | 1 ms | 2384 KB | Output is correct |
14 | Correct | 1 ms | 2384 KB | Output is correct |
15 | Correct | 1 ms | 2384 KB | Output is correct |
16 | Correct | 1 ms | 2384 KB | Output is correct |
17 | Correct | 1 ms | 2384 KB | Output is correct |
18 | Correct | 1 ms | 2384 KB | Output is correct |
19 | Correct | 1 ms | 2384 KB | Output is correct |
20 | Correct | 1 ms | 2384 KB | Output is correct |
21 | Correct | 2 ms | 2552 KB | Output is correct |
22 | Correct | 1 ms | 2384 KB | Output is correct |
23 | Correct | 1 ms | 2384 KB | Output is correct |
24 | Correct | 1 ms | 2384 KB | Output is correct |
25 | Correct | 1 ms | 2384 KB | Output is correct |
26 | Correct | 1 ms | 2384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 150 ms | 10952 KB | Output is correct |
2 | Correct | 153 ms | 11120 KB | Output is correct |
3 | Correct | 148 ms | 10952 KB | Output is correct |
4 | Correct | 148 ms | 10952 KB | Output is correct |
5 | Correct | 59 ms | 10952 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 37 ms | 6340 KB | Output is correct |
2 | Correct | 38 ms | 6348 KB | Output is correct |
3 | Correct | 38 ms | 6348 KB | Output is correct |
4 | Correct | 17 ms | 5840 KB | Output is correct |
5 | Correct | 1 ms | 2384 KB | Output is correct |
6 | Correct | 20 ms | 5968 KB | Output is correct |
7 | Correct | 30 ms | 6092 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 77 ms | 7888 KB | Output is correct |
2 | Correct | 77 ms | 7884 KB | Output is correct |
3 | Correct | 167 ms | 10952 KB | Output is correct |
4 | Correct | 68 ms | 10952 KB | Output is correct |
5 | Correct | 44 ms | 7884 KB | Output is correct |
6 | Correct | 73 ms | 10952 KB | Output is correct |
7 | Correct | 74 ms | 10952 KB | Output is correct |
8 | Correct | 64 ms | 7884 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2384 KB | Output is correct |
2 | Correct | 1 ms | 2384 KB | Output is correct |
3 | Correct | 1 ms | 2384 KB | Output is correct |
4 | Correct | 1 ms | 2384 KB | Output is correct |
5 | Correct | 1 ms | 2384 KB | Output is correct |
6 | Correct | 1 ms | 2556 KB | Output is correct |
7 | Correct | 1 ms | 2384 KB | Output is correct |
8 | Correct | 1 ms | 2384 KB | Output is correct |
9 | Correct | 1 ms | 2384 KB | Output is correct |
10 | Correct | 1 ms | 2384 KB | Output is correct |
11 | Correct | 1 ms | 2384 KB | Output is correct |
12 | Correct | 1 ms | 2384 KB | Output is correct |
13 | Correct | 1 ms | 2384 KB | Output is correct |
14 | Correct | 1 ms | 2384 KB | Output is correct |
15 | Correct | 1 ms | 2384 KB | Output is correct |
16 | Correct | 1 ms | 2384 KB | Output is correct |
17 | Correct | 1 ms | 2384 KB | Output is correct |
18 | Correct | 1 ms | 2384 KB | Output is correct |
19 | Correct | 1 ms | 2384 KB | Output is correct |
20 | Correct | 1 ms | 2384 KB | Output is correct |
21 | Correct | 2 ms | 2552 KB | Output is correct |
22 | Correct | 1 ms | 2384 KB | Output is correct |
23 | Correct | 1 ms | 2384 KB | Output is correct |
24 | Correct | 1 ms | 2384 KB | Output is correct |
25 | Correct | 1 ms | 2384 KB | Output is correct |
26 | Correct | 1 ms | 2384 KB | Output is correct |
27 | Correct | 150 ms | 10952 KB | Output is correct |
28 | Correct | 153 ms | 11120 KB | Output is correct |
29 | Correct | 148 ms | 10952 KB | Output is correct |
30 | Correct | 148 ms | 10952 KB | Output is correct |
31 | Correct | 59 ms | 10952 KB | Output is correct |
32 | Correct | 37 ms | 6340 KB | Output is correct |
33 | Correct | 38 ms | 6348 KB | Output is correct |
34 | Correct | 38 ms | 6348 KB | Output is correct |
35 | Correct | 17 ms | 5840 KB | Output is correct |
36 | Correct | 1 ms | 2384 KB | Output is correct |
37 | Correct | 20 ms | 5968 KB | Output is correct |
38 | Correct | 30 ms | 6092 KB | Output is correct |
39 | Correct | 77 ms | 7888 KB | Output is correct |
40 | Correct | 77 ms | 7884 KB | Output is correct |
41 | Correct | 167 ms | 10952 KB | Output is correct |
42 | Correct | 68 ms | 10952 KB | Output is correct |
43 | Correct | 44 ms | 7884 KB | Output is correct |
44 | Correct | 73 ms | 10952 KB | Output is correct |
45 | Correct | 74 ms | 10952 KB | Output is correct |
46 | Correct | 64 ms | 7884 KB | Output is correct |
47 | Correct | 89 ms | 8544 KB | Output is correct |
48 | Correct | 81 ms | 8384 KB | Output is correct |
49 | Correct | 169 ms | 11960 KB | Output is correct |
50 | Correct | 65 ms | 10952 KB | Output is correct |
51 | Correct | 57 ms | 10952 KB | Output is correct |
52 | Correct | 84 ms | 10952 KB | Output is correct |
53 | Correct | 78 ms | 10952 KB | Output is correct |
54 | Correct | 87 ms | 10952 KB | Output is correct |
55 | Correct | 135 ms | 11448 KB | Output is correct |