Submission #384052

# Submission time Handle Problem Language Result Execution time Memory
384052 2021-03-31T09:24:16 Z iulia13 Global Warming (CEOI18_glo) C++14
100 / 100
115 ms 4204 KB
#include <iostream>

using namespace std;
const int nmax = 2e5 + 5;
int dp[nmax];
int dp2[nmax];
int v[nmax];
int a[nmax];
int bs(int st, int dr, int val, int a[])
{
    int x = 0;
    while (st <= dr)
    {
        int mid = (st + dr) / 2;
        if (a[mid] < val)
        {
            x = mid;
            st = mid + 1;
        }
        else
            dr = mid - 1;
    }
    return x;
}
int main()
{
    int n, x, i, l = 0, ans = 0;
    cin >> n >> x;
    for (i = 1; i <= n; i++)
        cin >> v[i];
    for (i = n; i; i--)
    {
        int poz = bs(1, l, -v[i], a);
        dp[i] = poz + 1;
        if (poz == l)
            l++;
        a[poz + 1] = -v[i];
        ans = max(ans, dp[i]);
    }
    l = 0;
    for (i = 1; i <= n; i++)
    {
        int poz = bs(1, l, (v[i] + x), a);
        ans = max(ans, dp[i] + poz);
        poz = bs(1, l, v[i], a);
        if (poz == l)
            l++;
        a[poz + 1] = v[i];
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 2 ms 364 KB Output is correct
20 Correct 2 ms 364 KB Output is correct
21 Correct 2 ms 364 KB Output is correct
22 Correct 2 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 115 ms 2156 KB Output is correct
2 Correct 113 ms 2156 KB Output is correct
3 Correct 115 ms 2212 KB Output is correct
4 Correct 115 ms 2284 KB Output is correct
5 Correct 72 ms 2668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 29 ms 1004 KB Output is correct
2 Correct 29 ms 1004 KB Output is correct
3 Correct 29 ms 1004 KB Output is correct
4 Correct 19 ms 1132 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 19 ms 1132 KB Output is correct
7 Correct 27 ms 1260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 1388 KB Output is correct
2 Correct 56 ms 2028 KB Output is correct
3 Correct 109 ms 3948 KB Output is correct
4 Correct 72 ms 3436 KB Output is correct
5 Correct 37 ms 2028 KB Output is correct
6 Correct 71 ms 3436 KB Output is correct
7 Correct 89 ms 4076 KB Output is correct
8 Correct 51 ms 2132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 2 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 1 ms 364 KB Output is correct
18 Correct 1 ms 364 KB Output is correct
19 Correct 2 ms 364 KB Output is correct
20 Correct 2 ms 364 KB Output is correct
21 Correct 2 ms 364 KB Output is correct
22 Correct 2 ms 364 KB Output is correct
23 Correct 1 ms 364 KB Output is correct
24 Correct 1 ms 364 KB Output is correct
25 Correct 1 ms 364 KB Output is correct
26 Correct 1 ms 364 KB Output is correct
27 Correct 115 ms 2156 KB Output is correct
28 Correct 113 ms 2156 KB Output is correct
29 Correct 115 ms 2212 KB Output is correct
30 Correct 115 ms 2284 KB Output is correct
31 Correct 72 ms 2668 KB Output is correct
32 Correct 29 ms 1004 KB Output is correct
33 Correct 29 ms 1004 KB Output is correct
34 Correct 29 ms 1004 KB Output is correct
35 Correct 19 ms 1132 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
37 Correct 19 ms 1132 KB Output is correct
38 Correct 27 ms 1260 KB Output is correct
39 Correct 57 ms 1388 KB Output is correct
40 Correct 56 ms 2028 KB Output is correct
41 Correct 109 ms 3948 KB Output is correct
42 Correct 72 ms 3436 KB Output is correct
43 Correct 37 ms 2028 KB Output is correct
44 Correct 71 ms 3436 KB Output is correct
45 Correct 89 ms 4076 KB Output is correct
46 Correct 51 ms 2132 KB Output is correct
47 Correct 58 ms 2028 KB Output is correct
48 Correct 59 ms 2028 KB Output is correct
49 Correct 114 ms 3844 KB Output is correct
50 Correct 73 ms 3436 KB Output is correct
51 Correct 66 ms 2796 KB Output is correct
52 Correct 75 ms 3564 KB Output is correct
53 Correct 75 ms 3564 KB Output is correct
54 Correct 95 ms 4204 KB Output is correct
55 Correct 111 ms 3976 KB Output is correct