Submission #168002

# Submission time Handle Problem Language Result Execution time Memory
168002 2019-12-11T06:51:15 Z kostia244 Global Warming (CEOI18_glo) C++17
100 / 100
58 ms 5612 KB
#include<bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using namespace std;
using ll = long long;
using vi = vector<ll>;
int n, x, ans = 0;
vi t;
int add(vi &lis, int i) {
	auto it = lower_bound(all(lis), i);
	if (it == lis.end()) {
		lis.pb(i);
		return lis.size()-1;
	} else {
		*it = i;
		return it-lis.begin();
	}
}
int lis(int l, int r, int d) {
	vi lis, lis2;
	while (l < r) {
		int i = add(lis, t[l]+d);
		int j = add(lis2, t[l]);
//		for(auto i : lis) cout << i << " ";cout << "\n";
//		for(auto i : lis2) cout << i << " " ;cout << "\n";
		if(i<lis2.size())
			lis2[i] = min(lis2[i], lis[i]);
		l++;
	}
	return lis2.size();
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> x;
	t.resize(n);
	for (auto &i : t)
		cin >> i;
//	if (x == 0)
//		return cout << lis(0, n), 0;
	cout << lis(0, n, -x);
//	if(x < 6) return cout << solve3();
//	for (int d = -x; d <= x; d+=x) {
//		for (int r = 0; r+1 < n; r++) {
//			t[r] += d;
////			if(t[r]>t[r+1]) {
//			cout << lis(0, n) << " ";
//			ans = max(ans, lis(0, n));
////			}
//		}
//		cout << '\n';
//	}
//	cout << ans;
}

Compilation message

glo.cpp: In function 'int lis(int, int, int)':
glo.cpp:27:7: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(i<lis2.size())
      ~^~~~~~~~~~~~
glo.cpp:24:7: warning: unused variable 'j' [-Wunused-variable]
   int j = add(lis2, t[l]);
       ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 380 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 416 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 58 ms 3832 KB Output is correct
2 Correct 58 ms 3892 KB Output is correct
3 Correct 57 ms 3832 KB Output is correct
4 Correct 57 ms 3832 KB Output is correct
5 Correct 39 ms 4872 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 1272 KB Output is correct
2 Correct 15 ms 1272 KB Output is correct
3 Correct 15 ms 1272 KB Output is correct
4 Correct 11 ms 1572 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 11 ms 1652 KB Output is correct
7 Correct 13 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 2168 KB Output is correct
2 Correct 30 ms 2040 KB Output is correct
3 Correct 58 ms 3832 KB Output is correct
4 Correct 39 ms 4844 KB Output is correct
5 Correct 21 ms 2676 KB Output is correct
6 Correct 38 ms 4840 KB Output is correct
7 Correct 40 ms 5484 KB Output is correct
8 Correct 26 ms 2168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 376 KB Output is correct
19 Correct 2 ms 376 KB Output is correct
20 Correct 2 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 380 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 2 ms 416 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 376 KB Output is correct
27 Correct 58 ms 3832 KB Output is correct
28 Correct 58 ms 3892 KB Output is correct
29 Correct 57 ms 3832 KB Output is correct
30 Correct 57 ms 3832 KB Output is correct
31 Correct 39 ms 4872 KB Output is correct
32 Correct 15 ms 1272 KB Output is correct
33 Correct 15 ms 1272 KB Output is correct
34 Correct 15 ms 1272 KB Output is correct
35 Correct 11 ms 1572 KB Output is correct
36 Correct 2 ms 376 KB Output is correct
37 Correct 11 ms 1652 KB Output is correct
38 Correct 13 ms 1272 KB Output is correct
39 Correct 29 ms 2168 KB Output is correct
40 Correct 30 ms 2040 KB Output is correct
41 Correct 58 ms 3832 KB Output is correct
42 Correct 39 ms 4844 KB Output is correct
43 Correct 21 ms 2676 KB Output is correct
44 Correct 38 ms 4840 KB Output is correct
45 Correct 40 ms 5484 KB Output is correct
46 Correct 26 ms 2168 KB Output is correct
47 Correct 29 ms 2040 KB Output is correct
48 Correct 29 ms 2104 KB Output is correct
49 Correct 57 ms 3836 KB Output is correct
50 Correct 39 ms 4824 KB Output is correct
51 Correct 34 ms 5348 KB Output is correct
52 Correct 41 ms 5120 KB Output is correct
53 Correct 40 ms 4972 KB Output is correct
54 Correct 42 ms 5612 KB Output is correct
55 Correct 49 ms 3880 KB Output is correct