Submission #926915

# Submission time Handle Problem Language Result Execution time Memory
926915 2024-02-14T04:33:30 Z Amaarsaa Global Warming (CEOI18_glo) C++14
100 / 100
49 ms 11644 KB
#include<bits/stdc++.h>

using namespace std;
using ll = long long ;
const int N = 2e5+ 2;

ll a[N], b[N], L[N], R[N];
int main() {
//	freopen("moocast.in", "r", stdin);
//	freopen("moocast.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll t, n, m, ans, s, sum, x, mid, y, r, p, i, j, lo, hi;

	cin >> n >> m;
	
	
	for (i = 1; i <= n; i ++) {
		cin >> a[i];
		b[n - i + 1] = a[i];
	}
	
	vector < ll > Lda(N, 0);
	for (i= 1; i <= n; i ++) {
		lo = 1;
		hi = N;
		while ( lo < hi) {
			mid = (lo + hi)/2;
			if ( Lda[mid] > b[i]) lo = mid + 1;
			else hi = mid;
		}
		L[n - i + 1] = lo;
		Lda[lo] = b[i];
	}
	vector < ll > Lca(N, 1e18);
	for (i = 1; i <= n; i ++) {
		lo = 1;
		hi = N;
		while ( lo < hi) {
			mid = (lo + hi)/2;
			if ( Lca[mid] < (a[i] + m)) lo = mid + 1;
			else hi = mid;
		}
		R[i] = lo - 1;
		
		lo = 1;
		hi = N;
		while ( lo < hi) {
			mid = (lo + hi)/2;
			if ( Lca[mid] < a[i]) lo = mid + 1;
			else hi = mid;
		}
		Lca[lo] = a[i];
	}
	ans = 0;
	for (i= 1; i <= n; i ++) {
		ans = max(ans, R[i] + L[i]);
	}
	cout << ans << endl;
	
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:13:5: warning: unused variable 't' [-Wunused-variable]
   13 |  ll t, n, m, ans, s, sum, x, mid, y, r, p, i, j, lo, hi;
      |     ^
glo.cpp:13:19: warning: unused variable 's' [-Wunused-variable]
   13 |  ll t, n, m, ans, s, sum, x, mid, y, r, p, i, j, lo, hi;
      |                   ^
glo.cpp:13:22: warning: unused variable 'sum' [-Wunused-variable]
   13 |  ll t, n, m, ans, s, sum, x, mid, y, r, p, i, j, lo, hi;
      |                      ^~~
glo.cpp:13:27: warning: unused variable 'x' [-Wunused-variable]
   13 |  ll t, n, m, ans, s, sum, x, mid, y, r, p, i, j, lo, hi;
      |                           ^
glo.cpp:13:35: warning: unused variable 'y' [-Wunused-variable]
   13 |  ll t, n, m, ans, s, sum, x, mid, y, r, p, i, j, lo, hi;
      |                                   ^
glo.cpp:13:38: warning: unused variable 'r' [-Wunused-variable]
   13 |  ll t, n, m, ans, s, sum, x, mid, y, r, p, i, j, lo, hi;
      |                                      ^
glo.cpp:13:41: warning: unused variable 'p' [-Wunused-variable]
   13 |  ll t, n, m, ans, s, sum, x, mid, y, r, p, i, j, lo, hi;
      |                                         ^
glo.cpp:13:47: warning: unused variable 'j' [-Wunused-variable]
   13 |  ll t, n, m, ans, s, sum, x, mid, y, r, p, i, j, lo, hi;
      |                                               ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7512 KB Output is correct
2 Correct 2 ms 7516 KB Output is correct
3 Correct 2 ms 7516 KB Output is correct
4 Correct 2 ms 7516 KB Output is correct
5 Correct 2 ms 7516 KB Output is correct
6 Correct 2 ms 7516 KB Output is correct
7 Correct 2 ms 7516 KB Output is correct
8 Correct 2 ms 7516 KB Output is correct
9 Correct 2 ms 7516 KB Output is correct
10 Correct 2 ms 7516 KB Output is correct
11 Correct 2 ms 7516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7512 KB Output is correct
2 Correct 2 ms 7516 KB Output is correct
3 Correct 2 ms 7516 KB Output is correct
4 Correct 2 ms 7516 KB Output is correct
5 Correct 2 ms 7516 KB Output is correct
6 Correct 2 ms 7516 KB Output is correct
7 Correct 2 ms 7516 KB Output is correct
8 Correct 2 ms 7516 KB Output is correct
9 Correct 2 ms 7516 KB Output is correct
10 Correct 2 ms 7516 KB Output is correct
11 Correct 2 ms 7516 KB Output is correct
12 Correct 2 ms 7516 KB Output is correct
13 Correct 2 ms 7516 KB Output is correct
14 Correct 2 ms 7516 KB Output is correct
15 Correct 2 ms 7516 KB Output is correct
16 Correct 2 ms 7516 KB Output is correct
17 Correct 2 ms 7516 KB Output is correct
18 Correct 2 ms 7516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7512 KB Output is correct
2 Correct 2 ms 7516 KB Output is correct
3 Correct 2 ms 7516 KB Output is correct
4 Correct 2 ms 7516 KB Output is correct
5 Correct 2 ms 7516 KB Output is correct
6 Correct 2 ms 7516 KB Output is correct
7 Correct 2 ms 7516 KB Output is correct
8 Correct 2 ms 7516 KB Output is correct
9 Correct 2 ms 7516 KB Output is correct
10 Correct 2 ms 7516 KB Output is correct
11 Correct 2 ms 7516 KB Output is correct
12 Correct 2 ms 7516 KB Output is correct
13 Correct 2 ms 7516 KB Output is correct
14 Correct 2 ms 7516 KB Output is correct
15 Correct 2 ms 7516 KB Output is correct
16 Correct 2 ms 7516 KB Output is correct
17 Correct 2 ms 7516 KB Output is correct
18 Correct 2 ms 7516 KB Output is correct
19 Correct 2 ms 7512 KB Output is correct
20 Correct 2 ms 7516 KB Output is correct
21 Correct 2 ms 7516 KB Output is correct
22 Correct 2 ms 7580 KB Output is correct
23 Correct 2 ms 7516 KB Output is correct
24 Correct 2 ms 7516 KB Output is correct
25 Correct 2 ms 7516 KB Output is correct
26 Correct 2 ms 7516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 9836 KB Output is correct
2 Correct 48 ms 9788 KB Output is correct
3 Correct 48 ms 9808 KB Output is correct
4 Correct 48 ms 9820 KB Output is correct
5 Correct 36 ms 9652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 8284 KB Output is correct
2 Correct 15 ms 8184 KB Output is correct
3 Correct 12 ms 8284 KB Output is correct
4 Correct 10 ms 8284 KB Output is correct
5 Correct 2 ms 7512 KB Output is correct
6 Correct 10 ms 8284 KB Output is correct
7 Correct 10 ms 8236 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 8536 KB Output is correct
2 Correct 21 ms 9556 KB Output is correct
3 Correct 42 ms 11576 KB Output is correct
4 Correct 44 ms 10984 KB Output is correct
5 Correct 20 ms 9052 KB Output is correct
6 Correct 31 ms 10844 KB Output is correct
7 Correct 33 ms 11356 KB Output is correct
8 Correct 18 ms 9544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 7512 KB Output is correct
2 Correct 2 ms 7516 KB Output is correct
3 Correct 2 ms 7516 KB Output is correct
4 Correct 2 ms 7516 KB Output is correct
5 Correct 2 ms 7516 KB Output is correct
6 Correct 2 ms 7516 KB Output is correct
7 Correct 2 ms 7516 KB Output is correct
8 Correct 2 ms 7516 KB Output is correct
9 Correct 2 ms 7516 KB Output is correct
10 Correct 2 ms 7516 KB Output is correct
11 Correct 2 ms 7516 KB Output is correct
12 Correct 2 ms 7516 KB Output is correct
13 Correct 2 ms 7516 KB Output is correct
14 Correct 2 ms 7516 KB Output is correct
15 Correct 2 ms 7516 KB Output is correct
16 Correct 2 ms 7516 KB Output is correct
17 Correct 2 ms 7516 KB Output is correct
18 Correct 2 ms 7516 KB Output is correct
19 Correct 2 ms 7512 KB Output is correct
20 Correct 2 ms 7516 KB Output is correct
21 Correct 2 ms 7516 KB Output is correct
22 Correct 2 ms 7580 KB Output is correct
23 Correct 2 ms 7516 KB Output is correct
24 Correct 2 ms 7516 KB Output is correct
25 Correct 2 ms 7516 KB Output is correct
26 Correct 2 ms 7516 KB Output is correct
27 Correct 47 ms 9836 KB Output is correct
28 Correct 48 ms 9788 KB Output is correct
29 Correct 48 ms 9808 KB Output is correct
30 Correct 48 ms 9820 KB Output is correct
31 Correct 36 ms 9652 KB Output is correct
32 Correct 12 ms 8284 KB Output is correct
33 Correct 15 ms 8184 KB Output is correct
34 Correct 12 ms 8284 KB Output is correct
35 Correct 10 ms 8284 KB Output is correct
36 Correct 2 ms 7512 KB Output is correct
37 Correct 10 ms 8284 KB Output is correct
38 Correct 10 ms 8236 KB Output is correct
39 Correct 21 ms 8536 KB Output is correct
40 Correct 21 ms 9556 KB Output is correct
41 Correct 42 ms 11576 KB Output is correct
42 Correct 44 ms 10984 KB Output is correct
43 Correct 20 ms 9052 KB Output is correct
44 Correct 31 ms 10844 KB Output is correct
45 Correct 33 ms 11356 KB Output is correct
46 Correct 18 ms 9544 KB Output is correct
47 Correct 25 ms 9560 KB Output is correct
48 Correct 25 ms 9564 KB Output is correct
49 Correct 49 ms 11612 KB Output is correct
50 Correct 38 ms 10868 KB Output is correct
51 Correct 31 ms 9820 KB Output is correct
52 Correct 38 ms 11100 KB Output is correct
53 Correct 32 ms 11100 KB Output is correct
54 Correct 34 ms 11604 KB Output is correct
55 Correct 39 ms 11644 KB Output is correct