Submission #827394

# Submission time Handle Problem Language Result Execution time Memory
827394 2023-08-16T12:25:09 Z MadokaMagicaFan Global Warming (CEOI18_glo) C++14
100 / 100
216 ms 5380 KB
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define pb push_back
#define sz(v) ((int)v.size())

const ll inf = 1e16;

vector<int> nm;

int bs(int x) {
	int l, r, m;
	l = 0;
	r = sz(nm);
	while (l < r) {
		m = (l+r)/2;
		if (nm[m] <= x)
			l = m+1;
		else
			r = m;
	}
	return l;
}

struct aib {
	int n;
	vector<int> f;

	aib(int _n) : n(_n)
	{
		f.assign(n, 0);
	}

	void upd(int x, int v) {
		f[x] = max(f[x], v);
		for (; x < n; x |= (x+1))
			f[x] = max(f[x], v);
	}

	int qry(int x) {
		int r = 0;
		for (; x >=0; x = (x&(x+1))-1)
			r = max(f[x], r);
		return r;
	}
};

int main() {
	int n, d;
	cin >> n >> d;
	
	vector<int> t(n);
	for (int i = 0; i < n; ++i)
		cin >> t[i];
	nm = t;
	sort(nm.begin(), nm.end());
	nm.erase(unique(nm.begin(), nm.end()), nm.end());

	aib z[2] {sz(nm)+5, sz(nm)+5};
	
	for (auto x : t) {
		z[1].upd(bs(x), 1 + z[1].qry(bs(x-1)));
		z[1].upd(bs(x), 1 + z[0].qry(bs(x + d-1)));
		z[0].upd(bs(x), 1 + z[0].qry(bs(x-1)));
	}

	cout << max(z[0].qry(sz(nm)+4), z[1].qry(sz(nm)+4)) << endl;;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 296 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 296 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 296 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 296 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 296 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 300 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 296 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 296 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 296 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 300 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 210 ms 3428 KB Output is correct
2 Correct 215 ms 3396 KB Output is correct
3 Correct 216 ms 3372 KB Output is correct
4 Correct 211 ms 3428 KB Output is correct
5 Correct 97 ms 2648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 1072 KB Output is correct
2 Correct 48 ms 1080 KB Output is correct
3 Correct 47 ms 1076 KB Output is correct
4 Correct 23 ms 852 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 24 ms 1084 KB Output is correct
7 Correct 42 ms 1512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 92 ms 1860 KB Output is correct
2 Correct 92 ms 1848 KB Output is correct
3 Correct 193 ms 3404 KB Output is correct
4 Correct 93 ms 2636 KB Output is correct
5 Correct 59 ms 1748 KB Output is correct
6 Correct 106 ms 3224 KB Output is correct
7 Correct 120 ms 3204 KB Output is correct
8 Correct 80 ms 1848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 296 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 296 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 300 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 296 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 300 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 210 ms 3428 KB Output is correct
28 Correct 215 ms 3396 KB Output is correct
29 Correct 216 ms 3372 KB Output is correct
30 Correct 211 ms 3428 KB Output is correct
31 Correct 97 ms 2648 KB Output is correct
32 Correct 48 ms 1072 KB Output is correct
33 Correct 48 ms 1080 KB Output is correct
34 Correct 47 ms 1076 KB Output is correct
35 Correct 23 ms 852 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 24 ms 1084 KB Output is correct
38 Correct 42 ms 1512 KB Output is correct
39 Correct 92 ms 1860 KB Output is correct
40 Correct 92 ms 1848 KB Output is correct
41 Correct 193 ms 3404 KB Output is correct
42 Correct 93 ms 2636 KB Output is correct
43 Correct 59 ms 1748 KB Output is correct
44 Correct 106 ms 3224 KB Output is correct
45 Correct 120 ms 3204 KB Output is correct
46 Correct 80 ms 1848 KB Output is correct
47 Correct 100 ms 2728 KB Output is correct
48 Correct 99 ms 2824 KB Output is correct
49 Correct 215 ms 5280 KB Output is correct
50 Correct 98 ms 3804 KB Output is correct
51 Correct 91 ms 3108 KB Output is correct
52 Correct 157 ms 4716 KB Output is correct
53 Correct 111 ms 4684 KB Output is correct
54 Correct 128 ms 5380 KB Output is correct
55 Correct 181 ms 5324 KB Output is correct