Submission #471134

# Submission time Handle Problem Language Result Execution time Memory
471134 2021-09-07T12:58:59 Z zxcvbnm Global Warming (CEOI18_glo) C++14
62 / 100
100 ms 12684 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
void get(vector<int>& suff, vector<int>& suff_len, vector<int> a) {
    reverse(a.begin(), a.end());
    set<int> s;

    for(int i = 0; i < (int) a.size(); i++) {
        auto it = s.upper_bound(a[i]);
        if (it == s.begin()) {
            s.insert(a[i]);
        }
        else {
            it--;
            s.erase(it);
            s.insert(a[i]);
        }
        suff.push_back(*s.begin());
        suff_len.push_back(s.size());
//        for(int j : suff) {
//            cout << j << " ";
//        } cout << "\n";
    }
    reverse(suff.begin(), suff.end());
    reverse(suff_len.begin(), suff_len.end());
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, x;
    cin >> n >> x;
    vector<int> a(n);
    for(int& i : a) {
        cin >> i;
    }

    int ans = 0;
    vector<int> suff, suff_len;
    get(suff, suff_len, a);
    for(int& i : suff) {
        i += x;
    }
    suff.push_back(INT_MAX);
    suff_len.push_back(0);

    vector<int> dp;
    for(int i = 0; i < n; i++) {
        int pos = lower_bound(dp.begin(), dp.end(), a[i]) - dp.begin();
        if (pos == (int) dp.size()) {
            dp.push_back(a[i]);
        }
        else {
            dp[pos] = a[i];
        }

        ans = max(ans, (int) dp.size());
        auto it = lower_bound(dp.begin(), dp.end(), suff[i+1]);
        if (it == dp.begin()) continue;
        it--;
        if (it == dp.end()) continue;
        ans = max(ans, (it - dp.begin() + 1) + suff_len[i+1]);
    }

    cout << ans << "\n";
//    for(int i = 0; i < n; i++) {
//        cout << suff[i] << " " << suff_len[i] << "\n";
//    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 308 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 308 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 272 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 316 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 308 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 272 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 316 KB Output is correct
19 Incorrect 1 ms 332 KB Output isn't correct
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 86 ms 7204 KB Output is correct
2 Correct 80 ms 7244 KB Output is correct
3 Correct 84 ms 7268 KB Output is correct
4 Correct 81 ms 7212 KB Output is correct
5 Correct 100 ms 11864 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 22 ms 2504 KB Output is correct
2 Correct 20 ms 2504 KB Output is correct
3 Correct 27 ms 2524 KB Output is correct
4 Correct 20 ms 3268 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 23 ms 3240 KB Output is correct
7 Correct 17 ms 2516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 4204 KB Output is correct
2 Correct 40 ms 4616 KB Output is correct
3 Correct 81 ms 8632 KB Output is correct
4 Correct 96 ms 12440 KB Output is correct
5 Correct 44 ms 6312 KB Output is correct
6 Correct 70 ms 11904 KB Output is correct
7 Correct 82 ms 12684 KB Output is correct
8 Correct 34 ms 4544 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 308 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 0 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 272 KB Output is correct
15 Correct 1 ms 204 KB Output is correct
16 Correct 1 ms 204 KB Output is correct
17 Correct 1 ms 204 KB Output is correct
18 Correct 1 ms 316 KB Output is correct
19 Incorrect 1 ms 332 KB Output isn't correct
20 Halted 0 ms 0 KB -