Submission #198974

# Submission time Handle Problem Language Result Execution time Memory
198974 2020-01-28T13:38:12 Z osaaateiasavtnl Triple Jump (JOI19_jumps) C++14
5 / 100
4000 ms 10336 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
const int N = 5e5 + 7;
int n, q, a[N];
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n;
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    vector <ii> p;
    vector <int> s;
    for (int i = 0; i < n; ++i) {
        while (s.size() && a[s.back()] <= a[i]) {
            p.app(mp(s.back(), i));
            s.pop_back();
        }       
        s.app(i);
    }
    s.clear();   
    for (int i = n - 1; i >= 0; --i) {
        while (s.size() && a[s.back()] <= a[i]) {
            p.app(mp(i, s.back()));
            s.pop_back();
        }       
        s.app(i);        
    }
    int q;
    cin >> q;
    while (q--) {
        int l, r;
        cin >> l >> r;
        --l; --r;
        int ans = 0;
        for (auto e : p) {
            if (l <= e.f && e.s <= r) {
                for (int i = e.s + (e.s - e.f); i <= r; ++i)
                    ans = max(ans, a[i] + a[e.f] + a[e.s]);
            }
        }   
        cout << ans << '\n';
    }   
}   
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Execution timed out 4075 ms 760 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4070 ms 10336 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Execution timed out 4075 ms 760 KB Time limit exceeded
12 Halted 0 ms 0 KB -