Submission #200643

# Submission time Handle Problem Language Result Execution time Memory
200643 2020-02-07T19:12:43 Z tincamatei Triple Jump (JOI19_jumps) C++14
19 / 100
913 ms 144120 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[j][i] = 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);
   ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 6 ms 1144 KB Output is correct
3 Correct 5 ms 1148 KB Output is correct
4 Correct 5 ms 1144 KB Output is correct
5 Correct 6 ms 1144 KB Output is correct
6 Correct 5 ms 1144 KB Output is correct
7 Correct 5 ms 1144 KB Output is correct
8 Correct 6 ms 1144 KB Output is correct
9 Correct 5 ms 1144 KB Output is correct
10 Correct 5 ms 1144 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 6 ms 1144 KB Output is correct
3 Correct 5 ms 1148 KB Output is correct
4 Correct 5 ms 1144 KB Output is correct
5 Correct 6 ms 1144 KB Output is correct
6 Correct 5 ms 1144 KB Output is correct
7 Correct 5 ms 1144 KB Output is correct
8 Correct 6 ms 1144 KB Output is correct
9 Correct 5 ms 1144 KB Output is correct
10 Correct 5 ms 1144 KB Output is correct
11 Correct 901 ms 143892 KB Output is correct
12 Correct 903 ms 144120 KB Output is correct
13 Correct 898 ms 143992 KB Output is correct
14 Correct 913 ms 143980 KB Output is correct
15 Correct 909 ms 144120 KB Output is correct
16 Correct 910 ms 143352 KB Output is correct
17 Correct 903 ms 143328 KB Output is correct
18 Correct 901 ms 143224 KB Output is correct
19 Correct 904 ms 143996 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 342 ms 136168 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 6 ms 1144 KB Output is correct
3 Correct 5 ms 1148 KB Output is correct
4 Correct 5 ms 1144 KB Output is correct
5 Correct 6 ms 1144 KB Output is correct
6 Correct 5 ms 1144 KB Output is correct
7 Correct 5 ms 1144 KB Output is correct
8 Correct 6 ms 1144 KB Output is correct
9 Correct 5 ms 1144 KB Output is correct
10 Correct 5 ms 1144 KB Output is correct
11 Correct 901 ms 143892 KB Output is correct
12 Correct 903 ms 144120 KB Output is correct
13 Correct 898 ms 143992 KB Output is correct
14 Correct 913 ms 143980 KB Output is correct
15 Correct 909 ms 144120 KB Output is correct
16 Correct 910 ms 143352 KB Output is correct
17 Correct 903 ms 143328 KB Output is correct
18 Correct 901 ms 143224 KB Output is correct
19 Correct 904 ms 143996 KB Output is correct
20 Runtime error 342 ms 136168 KB Execution killed with signal 11 (could be triggered by violating memory limits)
21 Halted 0 ms 0 KB -