답안 #489507

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
489507 2021-11-23T04:37:02 Z wiwiho 3단 점프 (JOI19_jumps) C++14
19 / 100
429 ms 524292 KB
#include<bits/stdc++.h>

#define mp make_pair
#define F first
#define S second
#define printv(a, b) { \
    for(auto pv : a) b << pv << " "; \
    b << "\n";\
}
#define eb emplace_back

using namespace std;

typedef long long ll;

using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    vector<ll> a(n + 1);
    for(int i = 1; i <= n; i++) cin >> a[i];

    vector<vector<ll>> dp(n + 1, vector<ll>(n + 1));

    for(int i = 1; i + 2 <= n; i++){
        ll mx = a[i + 1];
        int p = i + 1;
        for(int j = i + 2; j <= n; j++){
            while(p + 1 - i <= j - p - 1){
                p++;
                mx = max(mx, a[p]);
            }
            //cerr << i << " " << j << " " << p << "\n";
            dp[i][j] = a[i] + a[j] + mx;
        }
    }

    for(int len = 3; len <= n; len++){
        for(int i = 1; i + len <= n; i++){
            int j = i + len;
            dp[i][j] = max({dp[i][j], dp[i][j - 1], dp[i + 1][j]});
        }
    }
    
    int q;
    cin >> q;
    while(q--){
        int l, r;
        cin >> l >> r;
        cout << dp[l][r] << "\n";
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 312 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 396 KB Output is correct
10 Correct 1 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 312 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 396 KB Output is correct
10 Correct 1 ms 312 KB Output is correct
11 Correct 423 ms 203468 KB Output is correct
12 Correct 425 ms 203496 KB Output is correct
13 Correct 423 ms 203448 KB Output is correct
14 Correct 428 ms 203516 KB Output is correct
15 Correct 410 ms 203452 KB Output is correct
16 Correct 429 ms 202800 KB Output is correct
17 Correct 421 ms 202900 KB Output is correct
18 Correct 429 ms 203016 KB Output is correct
19 Correct 415 ms 203588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 249 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
4 Correct 0 ms 332 KB Output is correct
5 Correct 0 ms 312 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 0 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 Correct 0 ms 396 KB Output is correct
10 Correct 1 ms 312 KB Output is correct
11 Correct 423 ms 203468 KB Output is correct
12 Correct 425 ms 203496 KB Output is correct
13 Correct 423 ms 203448 KB Output is correct
14 Correct 428 ms 203516 KB Output is correct
15 Correct 410 ms 203452 KB Output is correct
16 Correct 429 ms 202800 KB Output is correct
17 Correct 421 ms 202900 KB Output is correct
18 Correct 429 ms 203016 KB Output is correct
19 Correct 415 ms 203588 KB Output is correct
20 Runtime error 249 ms 524292 KB Execution killed with signal 9
21 Halted 0 ms 0 KB -