답안 #677801

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
677801 2023-01-04T11:44:23 Z qwerasdfzxcl 3단 점프 (JOI19_jumps) C++17
19 / 100
497 ms 144304 KB
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
int a[5050], ans[5050][5050], dp[5050][5050];

int main(){
    int n;
    scanf("%d", &n);
    for (int i=1;i<=n;i++) scanf("%d", a+i);

    for (int i=1;i<=n;i++){
        int pt = i, val = 0;
        for (int j=i+2;j<=n;j++){
            if (pt+1 - i <= j - (pt+1)){
                ++pt;
                val = max(val, a[pt]);
            }
            ans[i][j] = a[i] + a[j] + val;
        }
    }

    for (int d=2;d<n;d++){
        for (int i=1;i<=n-d;i++){
            int j = i+d;
            dp[i][j] = max(ans[i][j], max(dp[i+1][j], dp[i][j-1]));
        }
    }

    int q;
    scanf("%d", &q);
    while(q--){
        int x, y;
        scanf("%d %d", &x, &y);
        printf("%d\n", dp[x][y]);
    }
    return 0;
}

Compilation message

jumps.cpp: In function 'int main()':
jumps.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
jumps.cpp:10:33: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     for (int i=1;i<=n;i++) scanf("%d", a+i);
      |                            ~~~~~^~~~~~~~~~~
jumps.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
jumps.cpp:34:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |         scanf("%d %d", &x, &y);
      |         ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1080 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1080 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 476 ms 144288 KB Output is correct
12 Correct 476 ms 144244 KB Output is correct
13 Correct 454 ms 144172 KB Output is correct
14 Correct 463 ms 144304 KB Output is correct
15 Correct 459 ms 144256 KB Output is correct
16 Correct 480 ms 143568 KB Output is correct
17 Correct 455 ms 143548 KB Output is correct
18 Correct 453 ms 143668 KB Output is correct
19 Correct 497 ms 144092 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 5 ms 636 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 1108 KB Output is correct
3 Correct 1 ms 1108 KB Output is correct
4 Correct 1 ms 1108 KB Output is correct
5 Correct 1 ms 1108 KB Output is correct
6 Correct 1 ms 1108 KB Output is correct
7 Correct 1 ms 1080 KB Output is correct
8 Correct 1 ms 1108 KB Output is correct
9 Correct 1 ms 1116 KB Output is correct
10 Correct 1 ms 1108 KB Output is correct
11 Correct 476 ms 144288 KB Output is correct
12 Correct 476 ms 144244 KB Output is correct
13 Correct 454 ms 144172 KB Output is correct
14 Correct 463 ms 144304 KB Output is correct
15 Correct 459 ms 144256 KB Output is correct
16 Correct 480 ms 143568 KB Output is correct
17 Correct 455 ms 143548 KB Output is correct
18 Correct 453 ms 143668 KB Output is correct
19 Correct 497 ms 144092 KB Output is correct
20 Runtime error 5 ms 636 KB Execution killed with signal 11
21 Halted 0 ms 0 KB -