Submission #655399

# Submission time Handle Problem Language Result Execution time Memory
655399 2022-11-04T08:53:48 Z piOOE Triple Jump (JOI19_jumps) C++17
27 / 100
23 ms 4788 KB
#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;

    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    vector<int> suf(a);
    for (int i = n - 2; i >= 0; --i) {
        suf[i] = max(suf[i + 1], suf[i]);
    }

    int ans = 0;

    auto relax = [&](int i, int j) {
        int r = j + (j - i);
        if (r < n) {
            ans = max(ans, a[i] + a[j] + suf[r]);
        }
    };

    vector<int> stk;


    for (int i = 0; i < n; ++i) {
        while (!stk.empty() && a[stk.back()] <= a[i]) {
            relax(stk.back(), i);
            stk.pop_back();
        }
        if (!stk.empty()) {
            relax(stk.back(), i);
        }
        stk.push_back(i);
    }

    cout << ans;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 316 KB Output is correct
2 Incorrect 1 ms 324 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 316 KB Output is correct
2 Incorrect 1 ms 324 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 3516 KB Output is correct
2 Correct 20 ms 3644 KB Output is correct
3 Correct 21 ms 4788 KB Output is correct
4 Correct 21 ms 3532 KB Output is correct
5 Correct 22 ms 3528 KB Output is correct
6 Correct 19 ms 2964 KB Output is correct
7 Correct 23 ms 2764 KB Output is correct
8 Correct 18 ms 2868 KB Output is correct
9 Correct 19 ms 3144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 316 KB Output is correct
2 Incorrect 1 ms 324 KB Output isn't correct
3 Halted 0 ms 0 KB -