#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
vector w(N + 2, vector<int64_t>(N + 1));
for (int i = 0; i < M; i++) {
w[X[i] + 1][Y[i] + 1] = W[i];
}
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= N; j++) {
w[i][j] += w[i][j - 1];
}
}
vector dp1(N + 1, vector<int64_t>(N));
for (int i = 1; i <= N; i++) {
for (int j = 0; j < N; j++) {
for (int k = 0; k <= j; k++) {
dp1[i][j] = max(dp1[i][j], dp1[i - 1][k] + w[i - 1][j + 1] - w[i - 1][k + 1]);
}
}
}
vector dp2(N + 1, vector<int64_t>(N));
for (int i = N - 1; i >= 0; i--) {
for (int j = 0; j < N; j++) {
for (int k = 0; k <= j; k++) {
dp2[i][j] = max(dp2[i][j], dp2[i + 1][k] + w[i + 2][j + 1] - w[i + 2][k + 1]);
}
}
}
int64_t ans = 0;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
ans = max(ans, dp1[i + 1][j] + dp2[i][j]);
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
717 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
745 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
745 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
717 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |