Submission #77315

# Submission time Handle Problem Language Result Execution time Memory
77315 2018-09-25T14:14:28 Z tmwilliamlin168 Global Warming (CEOI18_glo) C++14
100 / 100
171 ms 37368 KB
#include <bits/stdc++.h>
using namespace std;

const int mxN=2e5;
int n, x, t[mxN], ps[mxN], ft[2][mxN+1];

inline void upd(int k, int i, int x) {
	for(++i; i<=n; i+=i&-i)
		ft[k][i]=max(x, ft[k][i]);
}

inline int qry(int k, int i) {
	int r=0;
	for(; i; i-=i&-i)
		r=max(ft[k][i], r);
	return r;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> x;
	for(int i=0; i<n; ++i)
		cin >> t[i], ps[i]=t[i];
	sort(ps, ps+n);
	for(int i=0; i<n; ++i) {
		int p=lower_bound(ps, ps+n, t[i])-ps, a=qry(0, p), b=qry(0, lower_bound(ps, ps+n, t[i]+x)-ps), c=qry(1, p);
		upd(0, p, a+1);
		upd(1, p, max(b, c)+1);
	}
	cout << qry(1, n);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 516 KB Output is correct
3 Correct 2 ms 516 KB Output is correct
4 Correct 2 ms 516 KB Output is correct
5 Correct 2 ms 516 KB Output is correct
6 Correct 2 ms 516 KB Output is correct
7 Correct 2 ms 532 KB Output is correct
8 Correct 2 ms 536 KB Output is correct
9 Correct 2 ms 560 KB Output is correct
10 Correct 2 ms 560 KB Output is correct
11 Correct 2 ms 560 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 516 KB Output is correct
3 Correct 2 ms 516 KB Output is correct
4 Correct 2 ms 516 KB Output is correct
5 Correct 2 ms 516 KB Output is correct
6 Correct 2 ms 516 KB Output is correct
7 Correct 2 ms 532 KB Output is correct
8 Correct 2 ms 536 KB Output is correct
9 Correct 2 ms 560 KB Output is correct
10 Correct 2 ms 560 KB Output is correct
11 Correct 2 ms 560 KB Output is correct
12 Correct 2 ms 568 KB Output is correct
13 Correct 2 ms 572 KB Output is correct
14 Correct 2 ms 576 KB Output is correct
15 Correct 2 ms 628 KB Output is correct
16 Correct 2 ms 632 KB Output is correct
17 Correct 2 ms 676 KB Output is correct
18 Correct 2 ms 684 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 516 KB Output is correct
3 Correct 2 ms 516 KB Output is correct
4 Correct 2 ms 516 KB Output is correct
5 Correct 2 ms 516 KB Output is correct
6 Correct 2 ms 516 KB Output is correct
7 Correct 2 ms 532 KB Output is correct
8 Correct 2 ms 536 KB Output is correct
9 Correct 2 ms 560 KB Output is correct
10 Correct 2 ms 560 KB Output is correct
11 Correct 2 ms 560 KB Output is correct
12 Correct 2 ms 568 KB Output is correct
13 Correct 2 ms 572 KB Output is correct
14 Correct 2 ms 576 KB Output is correct
15 Correct 2 ms 628 KB Output is correct
16 Correct 2 ms 632 KB Output is correct
17 Correct 2 ms 676 KB Output is correct
18 Correct 2 ms 684 KB Output is correct
19 Correct 3 ms 728 KB Output is correct
20 Correct 3 ms 868 KB Output is correct
21 Correct 2 ms 868 KB Output is correct
22 Correct 3 ms 868 KB Output is correct
23 Correct 3 ms 868 KB Output is correct
24 Correct 2 ms 908 KB Output is correct
25 Correct 2 ms 908 KB Output is correct
26 Correct 2 ms 908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 136 ms 5984 KB Output is correct
2 Correct 138 ms 7840 KB Output is correct
3 Correct 138 ms 9912 KB Output is correct
4 Correct 171 ms 11884 KB Output is correct
5 Correct 70 ms 12260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 12260 KB Output is correct
2 Correct 41 ms 12260 KB Output is correct
3 Correct 30 ms 12260 KB Output is correct
4 Correct 17 ms 12260 KB Output is correct
5 Correct 2 ms 12260 KB Output is correct
6 Correct 17 ms 12588 KB Output is correct
7 Correct 27 ms 13128 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 14772 KB Output is correct
2 Correct 54 ms 15736 KB Output is correct
3 Correct 118 ms 19312 KB Output is correct
4 Correct 68 ms 19776 KB Output is correct
5 Correct 33 ms 19776 KB Output is correct
6 Correct 61 ms 22036 KB Output is correct
7 Correct 65 ms 23864 KB Output is correct
8 Correct 46 ms 23864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 516 KB Output is correct
3 Correct 2 ms 516 KB Output is correct
4 Correct 2 ms 516 KB Output is correct
5 Correct 2 ms 516 KB Output is correct
6 Correct 2 ms 516 KB Output is correct
7 Correct 2 ms 532 KB Output is correct
8 Correct 2 ms 536 KB Output is correct
9 Correct 2 ms 560 KB Output is correct
10 Correct 2 ms 560 KB Output is correct
11 Correct 2 ms 560 KB Output is correct
12 Correct 2 ms 568 KB Output is correct
13 Correct 2 ms 572 KB Output is correct
14 Correct 2 ms 576 KB Output is correct
15 Correct 2 ms 628 KB Output is correct
16 Correct 2 ms 632 KB Output is correct
17 Correct 2 ms 676 KB Output is correct
18 Correct 2 ms 684 KB Output is correct
19 Correct 3 ms 728 KB Output is correct
20 Correct 3 ms 868 KB Output is correct
21 Correct 2 ms 868 KB Output is correct
22 Correct 3 ms 868 KB Output is correct
23 Correct 3 ms 868 KB Output is correct
24 Correct 2 ms 908 KB Output is correct
25 Correct 2 ms 908 KB Output is correct
26 Correct 2 ms 908 KB Output is correct
27 Correct 136 ms 5984 KB Output is correct
28 Correct 138 ms 7840 KB Output is correct
29 Correct 138 ms 9912 KB Output is correct
30 Correct 171 ms 11884 KB Output is correct
31 Correct 70 ms 12260 KB Output is correct
32 Correct 31 ms 12260 KB Output is correct
33 Correct 41 ms 12260 KB Output is correct
34 Correct 30 ms 12260 KB Output is correct
35 Correct 17 ms 12260 KB Output is correct
36 Correct 2 ms 12260 KB Output is correct
37 Correct 17 ms 12588 KB Output is correct
38 Correct 27 ms 13128 KB Output is correct
39 Correct 55 ms 14772 KB Output is correct
40 Correct 54 ms 15736 KB Output is correct
41 Correct 118 ms 19312 KB Output is correct
42 Correct 68 ms 19776 KB Output is correct
43 Correct 33 ms 19776 KB Output is correct
44 Correct 61 ms 22036 KB Output is correct
45 Correct 65 ms 23864 KB Output is correct
46 Correct 46 ms 23864 KB Output is correct
47 Correct 63 ms 24408 KB Output is correct
48 Correct 66 ms 25372 KB Output is correct
49 Correct 164 ms 28896 KB Output is correct
50 Correct 69 ms 29668 KB Output is correct
51 Correct 61 ms 30188 KB Output is correct
52 Correct 85 ms 32228 KB Output is correct
53 Correct 63 ms 33500 KB Output is correct
54 Correct 74 ms 35396 KB Output is correct
55 Correct 111 ms 37368 KB Output is correct