답안 #515438

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
515438 2022-01-19T07:28:16 Z 79brue 3단 점프 (JOI19_jumps) C++14
0 / 100
4000 ms 2780 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int n, q;
int arr[500002];
int DP[5002][5002];
int DPmax[5002][5002];

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

    scanf("%d", &q);
    while(q--){
        int l, r;
        scanf("%d %d", &l, &r);
        int ans = 0;

        for(int b=l+1; b<r; b++){
            int aMax = 0, aVal = -1;
            for(int a=max(l, 2*b-r); a<b; a++){
                if(aVal <= arr[a]) aMax = a, aVal = arr[a];
            }
            for(int c=2*b-aMax; c<=r; c++) ans = max(ans, arr[aMax] + arr[b] + arr[c]);

            int cMax = 0, cVal = -1;
            for(int c=b+1; c<=r; c++){
                if(cVal <= arr[c]) cMax = c, cVal = arr[c];
            }
            for(int a=l; a<b; a++) if(b-a <= cMax-b) ans = max(ans, arr[a] + arr[b] + arr[cMax]);
        }
        printf("%d\n", ans);
    }
}

Compilation message

jumps.cpp: In function 'int main()':
jumps.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
jumps.cpp:14:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |     for(int i=1; i<=n; i++) scanf("%d", &arr[i]);
      |                             ~~~~~^~~~~~~~~~~~~~~
jumps.cpp:16:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
jumps.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         scanf("%d %d", &l, &r);
      |         ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Incorrect 1 ms 300 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Incorrect 1 ms 300 KB Output isn't correct
11 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4088 ms 2780 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 308 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 1 ms 308 KB Output is correct
10 Incorrect 1 ms 300 KB Output isn't correct
11 Halted 0 ms 0 KB -