# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
641102 |
2022-09-16T01:55:37 Z |
ymm |
Global Warming (CEOI18_glo) |
C++17 |
|
1884 ms |
4708 KB |
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;
const int N = 200'010;
int a[N];
int n, d;
int s1[N], s2[N];
__attribute__((optimize("O3,unroll-loops"),target("avx2")))
void up(int l, int r, int x)
{
Loop (i,l,r)
s2[i] = x;
}
int solve()
{
Loop (i,0,N)
s1[i] = s2[i] = INT_MAX;
Loop (i,0,n) {
int l = lower_bound(s2, s2 + N, a[i]) - s2;
int r = lower_bound(s1, s1 + N, a[i] + d) - s1;
s2[l] = a[i];
up(l+1, r+1, a[i]);
int j = lower_bound(s1, s1 + N, a[i]) - s1;
s1[j] = a[i];
//for (int x : s1) { if (x == INT_MAX) { break; } cout << x << ' '; } cout << "!\n";
//for (int x : s2) { if (x == INT_MAX) { break; } cout << x << ' '; } cout << "!\n";
//cout << "--\n\n";
}
return lower_bound(s2, s2+N, INT_MAX) - s2;
}
int main()
{
cin.tie(0) -> sync_with_stdio(false);
cin >> n >> d;
Loop (i,0,n)
cin >> a[i];
int ans = solve();
Loop (i,0,n) a[i] = -a[i];
reverse(a, a+n);
ans = max(ans, solve());
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1876 KB |
Output is correct |
2 |
Correct |
1 ms |
1876 KB |
Output is correct |
3 |
Correct |
1 ms |
1876 KB |
Output is correct |
4 |
Correct |
1 ms |
1876 KB |
Output is correct |
5 |
Correct |
2 ms |
1876 KB |
Output is correct |
6 |
Correct |
1 ms |
1876 KB |
Output is correct |
7 |
Correct |
1 ms |
1876 KB |
Output is correct |
8 |
Correct |
1 ms |
1876 KB |
Output is correct |
9 |
Correct |
1 ms |
1876 KB |
Output is correct |
10 |
Correct |
1 ms |
1832 KB |
Output is correct |
11 |
Correct |
1 ms |
1876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1876 KB |
Output is correct |
2 |
Correct |
1 ms |
1876 KB |
Output is correct |
3 |
Correct |
1 ms |
1876 KB |
Output is correct |
4 |
Correct |
1 ms |
1876 KB |
Output is correct |
5 |
Correct |
2 ms |
1876 KB |
Output is correct |
6 |
Correct |
1 ms |
1876 KB |
Output is correct |
7 |
Correct |
1 ms |
1876 KB |
Output is correct |
8 |
Correct |
1 ms |
1876 KB |
Output is correct |
9 |
Correct |
1 ms |
1876 KB |
Output is correct |
10 |
Correct |
1 ms |
1832 KB |
Output is correct |
11 |
Correct |
1 ms |
1876 KB |
Output is correct |
12 |
Correct |
1 ms |
1876 KB |
Output is correct |
13 |
Correct |
1 ms |
1876 KB |
Output is correct |
14 |
Correct |
1 ms |
1876 KB |
Output is correct |
15 |
Correct |
2 ms |
1876 KB |
Output is correct |
16 |
Correct |
2 ms |
1876 KB |
Output is correct |
17 |
Correct |
1 ms |
1876 KB |
Output is correct |
18 |
Correct |
1 ms |
1876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1876 KB |
Output is correct |
2 |
Correct |
1 ms |
1876 KB |
Output is correct |
3 |
Correct |
1 ms |
1876 KB |
Output is correct |
4 |
Correct |
1 ms |
1876 KB |
Output is correct |
5 |
Correct |
2 ms |
1876 KB |
Output is correct |
6 |
Correct |
1 ms |
1876 KB |
Output is correct |
7 |
Correct |
1 ms |
1876 KB |
Output is correct |
8 |
Correct |
1 ms |
1876 KB |
Output is correct |
9 |
Correct |
1 ms |
1876 KB |
Output is correct |
10 |
Correct |
1 ms |
1832 KB |
Output is correct |
11 |
Correct |
1 ms |
1876 KB |
Output is correct |
12 |
Correct |
1 ms |
1876 KB |
Output is correct |
13 |
Correct |
1 ms |
1876 KB |
Output is correct |
14 |
Correct |
1 ms |
1876 KB |
Output is correct |
15 |
Correct |
2 ms |
1876 KB |
Output is correct |
16 |
Correct |
2 ms |
1876 KB |
Output is correct |
17 |
Correct |
1 ms |
1876 KB |
Output is correct |
18 |
Correct |
1 ms |
1876 KB |
Output is correct |
19 |
Correct |
2 ms |
1876 KB |
Output is correct |
20 |
Correct |
2 ms |
1876 KB |
Output is correct |
21 |
Correct |
2 ms |
1876 KB |
Output is correct |
22 |
Correct |
2 ms |
1876 KB |
Output is correct |
23 |
Correct |
2 ms |
1876 KB |
Output is correct |
24 |
Correct |
1 ms |
1876 KB |
Output is correct |
25 |
Correct |
2 ms |
1876 KB |
Output is correct |
26 |
Correct |
2 ms |
1876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
87 ms |
2568 KB |
Output is correct |
2 |
Correct |
84 ms |
2644 KB |
Output is correct |
3 |
Correct |
89 ms |
2656 KB |
Output is correct |
4 |
Correct |
93 ms |
2644 KB |
Output is correct |
5 |
Correct |
61 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
21 ms |
2004 KB |
Output is correct |
2 |
Correct |
22 ms |
2088 KB |
Output is correct |
3 |
Correct |
22 ms |
2088 KB |
Output is correct |
4 |
Correct |
22 ms |
2004 KB |
Output is correct |
5 |
Correct |
2 ms |
1876 KB |
Output is correct |
6 |
Correct |
21 ms |
2044 KB |
Output is correct |
7 |
Correct |
17 ms |
2084 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
2164 KB |
Output is correct |
2 |
Correct |
41 ms |
2260 KB |
Output is correct |
3 |
Correct |
87 ms |
2636 KB |
Output is correct |
4 |
Correct |
369 ms |
2644 KB |
Output is correct |
5 |
Correct |
32 ms |
2260 KB |
Output is correct |
6 |
Correct |
1654 ms |
2612 KB |
Output is correct |
7 |
Correct |
1644 ms |
4476 KB |
Output is correct |
8 |
Correct |
40 ms |
3156 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1876 KB |
Output is correct |
2 |
Correct |
1 ms |
1876 KB |
Output is correct |
3 |
Correct |
1 ms |
1876 KB |
Output is correct |
4 |
Correct |
1 ms |
1876 KB |
Output is correct |
5 |
Correct |
2 ms |
1876 KB |
Output is correct |
6 |
Correct |
1 ms |
1876 KB |
Output is correct |
7 |
Correct |
1 ms |
1876 KB |
Output is correct |
8 |
Correct |
1 ms |
1876 KB |
Output is correct |
9 |
Correct |
1 ms |
1876 KB |
Output is correct |
10 |
Correct |
1 ms |
1832 KB |
Output is correct |
11 |
Correct |
1 ms |
1876 KB |
Output is correct |
12 |
Correct |
1 ms |
1876 KB |
Output is correct |
13 |
Correct |
1 ms |
1876 KB |
Output is correct |
14 |
Correct |
1 ms |
1876 KB |
Output is correct |
15 |
Correct |
2 ms |
1876 KB |
Output is correct |
16 |
Correct |
2 ms |
1876 KB |
Output is correct |
17 |
Correct |
1 ms |
1876 KB |
Output is correct |
18 |
Correct |
1 ms |
1876 KB |
Output is correct |
19 |
Correct |
2 ms |
1876 KB |
Output is correct |
20 |
Correct |
2 ms |
1876 KB |
Output is correct |
21 |
Correct |
2 ms |
1876 KB |
Output is correct |
22 |
Correct |
2 ms |
1876 KB |
Output is correct |
23 |
Correct |
2 ms |
1876 KB |
Output is correct |
24 |
Correct |
1 ms |
1876 KB |
Output is correct |
25 |
Correct |
2 ms |
1876 KB |
Output is correct |
26 |
Correct |
2 ms |
1876 KB |
Output is correct |
27 |
Correct |
87 ms |
2568 KB |
Output is correct |
28 |
Correct |
84 ms |
2644 KB |
Output is correct |
29 |
Correct |
89 ms |
2656 KB |
Output is correct |
30 |
Correct |
93 ms |
2644 KB |
Output is correct |
31 |
Correct |
61 ms |
2644 KB |
Output is correct |
32 |
Correct |
21 ms |
2004 KB |
Output is correct |
33 |
Correct |
22 ms |
2088 KB |
Output is correct |
34 |
Correct |
22 ms |
2088 KB |
Output is correct |
35 |
Correct |
22 ms |
2004 KB |
Output is correct |
36 |
Correct |
2 ms |
1876 KB |
Output is correct |
37 |
Correct |
21 ms |
2044 KB |
Output is correct |
38 |
Correct |
17 ms |
2084 KB |
Output is correct |
39 |
Correct |
41 ms |
2164 KB |
Output is correct |
40 |
Correct |
41 ms |
2260 KB |
Output is correct |
41 |
Correct |
87 ms |
2636 KB |
Output is correct |
42 |
Correct |
369 ms |
2644 KB |
Output is correct |
43 |
Correct |
32 ms |
2260 KB |
Output is correct |
44 |
Correct |
1654 ms |
2612 KB |
Output is correct |
45 |
Correct |
1644 ms |
4476 KB |
Output is correct |
46 |
Correct |
40 ms |
3156 KB |
Output is correct |
47 |
Correct |
43 ms |
3220 KB |
Output is correct |
48 |
Correct |
45 ms |
3224 KB |
Output is correct |
49 |
Correct |
92 ms |
4572 KB |
Output is correct |
50 |
Correct |
63 ms |
3812 KB |
Output is correct |
51 |
Correct |
55 ms |
3320 KB |
Output is correct |
52 |
Correct |
78 ms |
3836 KB |
Output is correct |
53 |
Correct |
1823 ms |
3924 KB |
Output is correct |
54 |
Correct |
1884 ms |
4608 KB |
Output is correct |
55 |
Correct |
72 ms |
4708 KB |
Output is correct |