# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
586609 | 2022-06-30T12:36:02 Z | aris12345678 | Global Warming (CEOI18_glo) | C++14 | 48 ms | 4424 KB |
#include <bits/stdc++.h> using namespace std; int main() { int N, X; scanf("%d %d", &N, &X); vector<int> A(N); for(int i = 0; i < N; i++) scanf("%d", &A[i]); vector<int> LIS; vector<int> INC(N, 0); LIS.push_back(A[0]); INC[0] = 1; for(int i = 1; i < N; i++) { int pos = lower_bound(LIS.begin(), LIS.end(), A[i])-LIS.begin(); INC[i] = pos+1; if(pos < LIS.size()) LIS[pos] = A[i]; else LIS.push_back(A[i]); } LIS.clear(); LIS.push_back(-A[N-1]); int ans = 0; for(int i = N-2; i >= 0; i--) { int len = lower_bound(LIS.begin(), LIS.end(), -A[i]+X)-LIS.begin(); ans = max(ans, INC[i]+len); int pos = lower_bound(LIS.begin(), LIS.end(), -A[i])-LIS.begin(); if(pos < LIS.size()) LIS[pos] = -A[i]; else LIS.push_back(-A[i]); } printf("%d\n", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 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 | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 300 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 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 | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 300 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 292 KB | Output is correct |
15 | Correct | 0 ms | 300 KB | Output is correct |
16 | Correct | 1 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 | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 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 | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 300 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 292 KB | Output is correct |
15 | Correct | 0 ms | 300 KB | Output is correct |
16 | Correct | 1 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 | 300 KB | Output is correct |
25 | Correct | 1 ms | 212 KB | Output is correct |
26 | Correct | 1 ms | 300 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 45 ms | 3796 KB | Output is correct |
2 | Correct | 48 ms | 3772 KB | Output is correct |
3 | Correct | 47 ms | 3800 KB | Output is correct |
4 | Correct | 45 ms | 3788 KB | Output is correct |
5 | Correct | 28 ms | 3664 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 1108 KB | Output is correct |
2 | Correct | 11 ms | 1076 KB | Output is correct |
3 | Correct | 11 ms | 1108 KB | Output is correct |
4 | Correct | 7 ms | 1108 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 1208 KB | Output is correct |
7 | Correct | 9 ms | 1108 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 2044 KB | Output is correct |
2 | Correct | 21 ms | 1964 KB | Output is correct |
3 | Correct | 46 ms | 3752 KB | Output is correct |
4 | Correct | 29 ms | 3652 KB | Output is correct |
5 | Correct | 14 ms | 1976 KB | Output is correct |
6 | Correct | 22 ms | 3592 KB | Output is correct |
7 | Correct | 30 ms | 4220 KB | Output is correct |
8 | Correct | 18 ms | 1972 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 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 | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 300 KB | Output is correct |
12 | Correct | 0 ms | 212 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 292 KB | Output is correct |
15 | Correct | 0 ms | 300 KB | Output is correct |
16 | Correct | 1 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 | 300 KB | Output is correct |
25 | Correct | 1 ms | 212 KB | Output is correct |
26 | Correct | 1 ms | 300 KB | Output is correct |
27 | Correct | 45 ms | 3796 KB | Output is correct |
28 | Correct | 48 ms | 3772 KB | Output is correct |
29 | Correct | 47 ms | 3800 KB | Output is correct |
30 | Correct | 45 ms | 3788 KB | Output is correct |
31 | Correct | 28 ms | 3664 KB | Output is correct |
32 | Correct | 11 ms | 1108 KB | Output is correct |
33 | Correct | 11 ms | 1076 KB | Output is correct |
34 | Correct | 11 ms | 1108 KB | Output is correct |
35 | Correct | 7 ms | 1108 KB | Output is correct |
36 | Correct | 0 ms | 212 KB | Output is correct |
37 | Correct | 7 ms | 1208 KB | Output is correct |
38 | Correct | 9 ms | 1108 KB | Output is correct |
39 | Correct | 20 ms | 2044 KB | Output is correct |
40 | Correct | 21 ms | 1964 KB | Output is correct |
41 | Correct | 46 ms | 3752 KB | Output is correct |
42 | Correct | 29 ms | 3652 KB | Output is correct |
43 | Correct | 14 ms | 1976 KB | Output is correct |
44 | Correct | 22 ms | 3592 KB | Output is correct |
45 | Correct | 30 ms | 4220 KB | Output is correct |
46 | Correct | 18 ms | 1972 KB | Output is correct |
47 | Correct | 22 ms | 1996 KB | Output is correct |
48 | Correct | 22 ms | 2004 KB | Output is correct |
49 | Correct | 46 ms | 3792 KB | Output is correct |
50 | Correct | 27 ms | 3664 KB | Output is correct |
51 | Correct | 23 ms | 2924 KB | Output is correct |
52 | Correct | 28 ms | 3760 KB | Output is correct |
53 | Correct | 24 ms | 3752 KB | Output is correct |
54 | Correct | 28 ms | 4424 KB | Output is correct |
55 | Correct | 39 ms | 3844 KB | Output is correct |