Submission #520945

# Submission time Handle Problem Language Result Execution time Memory
520945 2022-01-31T14:12:48 Z four_specks Global Warming (CEOI18_glo) C++17
100 / 100
50 ms 6852 KB
#include <bits/stdc++.h>

using namespace std;

inline namespace
{
} // namespace

void solve()
{
    int n;
    long x;
    cin >> n >> x;

    vector<long> t(n);
    for (int i = 0; i < n; i++)
        cin >> t[i];

    vector<long> lis, lds;

    vector<int> dp(n, 0);
    for (int i = n - 1; i >= 0; i--)
    {
        auto it = lower_bound(lds.begin(), lds.end(), -t[i]);
        dp[i] = (int)(it - lds.begin()) + 1;
        if (it == lds.end())
            lds.push_back(-t[i]);
        else
            *it = -t[i];
    }

    int len = 0;
    for (int i = 0; i < n; i++)
    {
        len = max(len, dp[i] + (int)(lower_bound(lis.begin(), lis.end(), t[i] + x) - lis.begin()));

        auto it = lower_bound(lis.begin(), lis.end(), t[i]);
        if (it == lis.end())
            lis.push_back(t[i]);
        else
            *it = t[i];
    }

    cout << len << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false), cin.tie(NULL);

    solve();

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 308 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 308 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 312 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 308 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 312 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 4540 KB Output is correct
2 Correct 45 ms 4548 KB Output is correct
3 Correct 50 ms 4588 KB Output is correct
4 Correct 47 ms 4556 KB Output is correct
5 Correct 28 ms 6072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1356 KB Output is correct
2 Correct 11 ms 1344 KB Output is correct
3 Correct 12 ms 1332 KB Output is correct
4 Correct 8 ms 1744 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 7 ms 1724 KB Output is correct
7 Correct 9 ms 1320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 2372 KB Output is correct
2 Correct 21 ms 2356 KB Output is correct
3 Correct 42 ms 4540 KB Output is correct
4 Correct 28 ms 6080 KB Output is correct
5 Correct 14 ms 3140 KB Output is correct
6 Correct 23 ms 6004 KB Output is correct
7 Correct 25 ms 6592 KB Output is correct
8 Correct 18 ms 2372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 308 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 308 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 0 ms 204 KB Output is correct
12 Correct 0 ms 204 KB Output is correct
13 Correct 0 ms 204 KB Output is correct
14 Correct 1 ms 308 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 0 ms 204 KB Output is correct
17 Correct 1 ms 312 KB Output is correct
18 Correct 0 ms 204 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 1 ms 332 KB Output is correct
21 Correct 1 ms 332 KB Output is correct
22 Correct 1 ms 332 KB Output is correct
23 Correct 1 ms 332 KB Output is correct
24 Correct 1 ms 332 KB Output is correct
25 Correct 1 ms 332 KB Output is correct
26 Correct 1 ms 332 KB Output is correct
27 Correct 45 ms 4540 KB Output is correct
28 Correct 45 ms 4548 KB Output is correct
29 Correct 50 ms 4588 KB Output is correct
30 Correct 47 ms 4556 KB Output is correct
31 Correct 28 ms 6072 KB Output is correct
32 Correct 12 ms 1356 KB Output is correct
33 Correct 11 ms 1344 KB Output is correct
34 Correct 12 ms 1332 KB Output is correct
35 Correct 8 ms 1744 KB Output is correct
36 Correct 0 ms 204 KB Output is correct
37 Correct 7 ms 1724 KB Output is correct
38 Correct 9 ms 1320 KB Output is correct
39 Correct 21 ms 2372 KB Output is correct
40 Correct 21 ms 2356 KB Output is correct
41 Correct 42 ms 4540 KB Output is correct
42 Correct 28 ms 6080 KB Output is correct
43 Correct 14 ms 3140 KB Output is correct
44 Correct 23 ms 6004 KB Output is correct
45 Correct 25 ms 6592 KB Output is correct
46 Correct 18 ms 2372 KB Output is correct
47 Correct 21 ms 2496 KB Output is correct
48 Correct 23 ms 2400 KB Output is correct
49 Correct 47 ms 4560 KB Output is correct
50 Correct 32 ms 6080 KB Output is correct
51 Correct 24 ms 5168 KB Output is correct
52 Correct 33 ms 6204 KB Output is correct
53 Correct 27 ms 6200 KB Output is correct
54 Correct 28 ms 6852 KB Output is correct
55 Correct 39 ms 4540 KB Output is correct