Submission #142878

# Submission time Handle Problem Language Result Execution time Memory
142878 2019-08-11T22:00:46 Z Sarah_Mokhtar Triple Jump (JOI19_jumps) C++14
5 / 100
4000 ms 5368 KB
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
typedef long long ll;
const int N=2e5+10,M=(N<<2),OO=0x3f3f3f;
ll tree[N],A[N],n,q,l,r;
void build(int node,int l,int r){
    if(l==r) tree[node]=A[l];
    else{
        int med=(l+r)/2;
        build(2*node,l,med);
        build(2*node+1,med+1,r);
        tree[node]=max(tree[2*node],tree[2*node+1]);
    }
}
int query(int node,int s,int e,int l,int r){
    if(s>e||s>r||e<l) return 0;
    if(s>=l&&e<=r) return tree[node];
    int med=(s+e)/2;
    int q1=query(2*node,s,med,l,r);
    int q2=query(2*node+1,med+1,e,l,r);
    return max(q1,q2);
}
int main(){
    cin>>n;
    for(int i=0;i<n;++i) cin>>A[i];
    build(1,0,n-1);
    cin>>q;
    //cout<<query(1,0,n-1,1,2)<<"\n";
    while(q--){
        cin>>l>>r;
        --l,--r;
        ll mx=0;
        for(int i=l;i<=r;++i){
            ll sum=0;
            for(int j=i+1;j<=r;++j){
                sum=A[i]+A[j];
                int dis=abs(j-i);
                int int1=j+dis,int2=r;
                if(int1<l||int1>r) continue;
                ll ans=query(1,0,n-1,int1,int2);
                //cout<<ans<<"\n";
                sum+=ans;
                mx=max(mx,sum);
            }
        }
        cout<<mx<<"\n";
    }
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 6 ms 380 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 6 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 7 ms 376 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 6 ms 380 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 6 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 7 ms 376 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Execution timed out 4018 ms 660 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 138 ms 5368 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 6 ms 376 KB Output is correct
5 Correct 6 ms 380 KB Output is correct
6 Correct 6 ms 376 KB Output is correct
7 Correct 6 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 7 ms 376 KB Output is correct
10 Correct 6 ms 376 KB Output is correct
11 Execution timed out 4018 ms 660 KB Time limit exceeded
12 Halted 0 ms 0 KB -