#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 3e3 + 100;
const int maxl = 11;
int n;
ll dp[maxn][maxn][2];
ll a[maxn][maxn];
long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W){
n = N;
for(int i = 0; i < M; i++){
X[i]++; Y[i]++;
a[X[i]][Y[i]] += W[i];
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
a[i][j] += a[i][j-1];
}
}
for(int i = 2; i <= n; i++){
for(int j = 0; j <= n; j++){
dp[i][j][0] = dp[i][j][1] = -1e18;
}
}
for(int i = 1; i < n; i++){
for(int j = 0; j <= n; j++){
for(int k = 0; k <= n; k++){
if(k >= j) dp[i+1][k][1] = max(dp[i+1][k][1], dp[i][j][1] + a[i][k] - a[i][j]);
if(k <= j) dp[i+1][k][0] = max(dp[i+1][k][0], max(dp[i][j][1], dp[i][j][0]) + a[i+1][j] - a[i+1][k]);
if(i > 1){
dp[i+1][k][0] = max(dp[i+1][k][0], dp[i-1][j][0] + a[i][max(j, k)]);
dp[i+1][k][1] = max(dp[i+1][k][1], dp[i-1][j][0] + a[i][max(j, k)]);
}
}
}
}
ll res = 0;
for(int i = 1; i <= n; i++){
for(int j = 0; j <= n; j++){
for(int c = 0; c < 2; c++){
res = max(res, dp[i][j][c]);
}
}
}
return res;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
604 ms |
463192 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Runtime error |
625 ms |
468508 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
594 ms |
458068 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
10 ms |
14868 KB |
Output is correct |
10 |
Correct |
65 ms |
25192 KB |
Output is correct |
11 |
Correct |
10 ms |
14680 KB |
Output is correct |
12 |
Incorrect |
65 ms |
24924 KB |
1st lines differ - on the 1st token, expected: '450122905247', found: '448985384286' |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
10 ms |
14868 KB |
Output is correct |
10 |
Correct |
65 ms |
25192 KB |
Output is correct |
11 |
Correct |
10 ms |
14680 KB |
Output is correct |
12 |
Incorrect |
65 ms |
24924 KB |
1st lines differ - on the 1st token, expected: '450122905247', found: '448985384286' |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
0 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
10 ms |
14868 KB |
Output is correct |
10 |
Correct |
65 ms |
25192 KB |
Output is correct |
11 |
Correct |
10 ms |
14680 KB |
Output is correct |
12 |
Incorrect |
65 ms |
24924 KB |
1st lines differ - on the 1st token, expected: '450122905247', found: '448985384286' |
13 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
594 ms |
458068 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
604 ms |
463192 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |