답안 #200642

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
200642 2020-02-07T19:11:39 Z tincamatei 3단 점프 (JOI19_jumps) C++14
0 / 100
301 ms 136312 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 5000;

int v[1+MAX_N], maxRange[1+MAX_N][1+MAX_N], dp[1+MAX_N][1+MAX_N];

int main() {
	int N, Q;

	scanf("%d", &N);
	for(int i = 1; i <= N; ++i) {
		scanf("%d", &v[i]);
		for(int j = i; j >= 1; --j)
			maxRange[i][j] = max(maxRange[j + 1][i], v[j]);
	}

	for(int d = 3; d <= N; ++d)
		for(int i = 1; i + d - 1 <= N; ++i) {
			int j = i + d - 1;

			dp[i][j] = max(v[i] + v[j] + maxRange[i + 1][(i + j) / 2], max(dp[i + 1][j], dp[i][j - 1]));
		}

	scanf("%d", &Q);
	for(int i = 0; i < Q; ++i) {
		int l, r;
		scanf("%d%d", &l, &r);
		printf("%d\n", dp[l][r]);
	}
	return 0;
}

Compilation message

jumps.cpp: In function 'int main()':
jumps.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
jumps.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &v[i]);
   ~~~~~^~~~~~~~~~~~~
jumps.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &Q);
  ~~~~~^~~~~~~~~~
jumps.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &l, &r);
   ~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 5 ms 1144 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 5 ms 1144 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 301 ms 136312 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 5 ms 1144 KB Output isn't correct
3 Halted 0 ms 0 KB -