Submission #807427

# Submission time Handle Problem Language Result Execution time Memory
807427 2023-08-04T17:17:44 Z oscar1f Triple Jump (JOI19_jumps) C++17
32 / 100
4000 ms 10756 KB
#include<bits/stdc++.h>
using namespace std;

#define int long long

const int MAX_VAL=500*1000+5,INFINI=1000*1000*1000;
int nbVal,nbReq,debReq,finReq,rep;
int val[MAX_VAL];
int maxi[MAX_VAL];
vector<int> enCours;
vector<pair<int,int>> paireInter;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>nbVal;
    for (int i=1;i<=nbVal;i++) {
        cin>>val[i];
    }
    enCours.push_back(1);
    for (int i=2;i<=nbVal;i++) {
        while (!enCours.empty() and val[enCours.back()]<=val[i]) {
            if (nbVal-i>=i-enCours.back()) {
                paireInter.push_back({enCours.back(),i});
            }
            enCours.pop_back();
        } 
        if (!enCours.empty()) {
            if (nbVal-i>=i-enCours.back()) {
                paireInter.push_back({enCours.back(),i});
            }
        }
        enCours.push_back(i);
    }
    /*for (auto i:paireInter) {
        cout<<i.first<<" "<<i.second<<endl;
    }
    cout<<endl;*/
    cin>>nbReq;
    for (int ireq=1;ireq<=nbReq;ireq++) {
        cin>>debReq>>finReq;
        maxi[finReq+1]=0;
        for (int i=finReq;i>=debReq;i--) {
            maxi[i]=max(maxi[i+1],val[i]);
        }
        rep=0;
        for (auto i:paireInter) {
            if (i.first>=debReq and 2*i.second-i.first<=finReq) {
                //cout<<i.first<<" "<<i.second<<endl;
                rep=max(rep,val[i.first]+val[i.second]+maxi[2*i.second-i.first]);
            }
        }
        cout<<rep<<"\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Execution timed out 4048 ms 4768 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 24 ms 10176 KB Output is correct
2 Correct 20 ms 7232 KB Output is correct
3 Correct 21 ms 10648 KB Output is correct
4 Correct 34 ms 10756 KB Output is correct
5 Correct 24 ms 10644 KB Output is correct
6 Correct 27 ms 10632 KB Output is correct
7 Correct 20 ms 10584 KB Output is correct
8 Correct 20 ms 10564 KB Output is correct
9 Correct 21 ms 10540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Execution timed out 4048 ms 4768 KB Time limit exceeded
12 Halted 0 ms 0 KB -