답안 #1013009

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1013009 2024-07-03T05:10:17 Z Aiperiii 3단 점프 (JOI19_jumps) C++14
19 / 100
4000 ms 201424 KB
#include <bits/stdc++.h>
#define int long long
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pb push_back
using namespace std;
int ans[5005][5005];
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
        vector <int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n-2;i++){
        int mx=a[i+1];
        vector <int> v;v.pb(a[i+1]);
        for(int j=i+2;j<n;j++){
            int sum=a[j]+a[i];
            mx=max(mx,a[j]);
            v.pb(mx);
            ans[i][j]=sum+v[v.size()/2-1];
        }
       
    }
    
    for(int i=0;i<n;i++){
        int pr=0;
        for(int j=0;j<n;j++){
            ans[i][j]=max(ans[i][j],pr);
            pr=ans[i][j];
        }
    }
   
    for(int j=0;j<n;j++){
        int pr=0;
        for(int i=n-1;i>=0;i--){
            ans[i][j]=max(ans[i][j],pr);
            pr=ans[i][j];
        }
    }
    
    int q;
    cin>>q;
    while(q--){
        int l,r;
        cin>>l>>r;
        l--;r--;
        cout<<ans[l][r]<<"\n";
    }
}



/*
 5
 5 2 1 5 3
 3
 1 4
 2 5
 1 5

 */



# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 427 ms 201408 KB Output is correct
12 Correct 423 ms 201292 KB Output is correct
13 Correct 428 ms 201300 KB Output is correct
14 Correct 424 ms 201424 KB Output is correct
15 Correct 443 ms 201300 KB Output is correct
16 Correct 435 ms 200756 KB Output is correct
17 Correct 434 ms 200788 KB Output is correct
18 Correct 448 ms 200784 KB Output is correct
19 Correct 448 ms 201300 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4065 ms 86952 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 427 ms 201408 KB Output is correct
12 Correct 423 ms 201292 KB Output is correct
13 Correct 428 ms 201300 KB Output is correct
14 Correct 424 ms 201424 KB Output is correct
15 Correct 443 ms 201300 KB Output is correct
16 Correct 435 ms 200756 KB Output is correct
17 Correct 434 ms 200788 KB Output is correct
18 Correct 448 ms 200784 KB Output is correct
19 Correct 448 ms 201300 KB Output is correct
20 Execution timed out 4065 ms 86952 KB Time limit exceeded
21 Halted 0 ms 0 KB -