#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 = 1; i <= n + 1; i++){
for(int j = 0; j <= n; j++){
dp[i][j][0] = dp[i][j][1] = -(ll)1e18;
if(i == 1) dp[i][j][1] = dp[i][j][0] = 0;
}
}
for(int i = 1; i <= n; i++){
for(int j = 0; j <= n; j++){
for(int k = 0; k <= n; k++){
if(j <= k){
dp[i+1][k][1] = max(dp[i+1][k][1], dp[i][j][1] + a[i][k] - a[i][j]);
}
if(j >= k){
dp[i+1][k][0] = max(dp[i+1][k][0], dp[i][j][0] + a[i+1][j] - a[i+1][k]);
}
if(i < n){
dp[i+2][k][0] = max(dp[i+2][k][0], dp[i][j][1] + a[i][n] + a[i+2][n] - a[i][j] - a[i+2][k]);
dp[i+2][k][1] = max(dp[i+2][k][1], dp[i][j][0] + a[i+1][max(j, k)]);
}
}
}
}
// for(int i = 1; i <= n; i++){
// for(int j = 0; j <= n; j++){
// cout << dp[i][j][0] << ' ';
// } cout << endl;
// for(int j = 0; j <= n; j++){
// cout << dp[i][j][1] << ' ';
// } cout << endl << endl;
// }
return max(dp[n+1][0][0], dp[n+1][0][1]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
790 ms |
461848 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Runtime error |
740 ms |
465796 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
760 ms |
457824 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 |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
10 ms |
2140 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '185689573686' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
10 ms |
2140 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '185689573686' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
10 ms |
2140 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '185689573686' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
760 ms |
457824 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
790 ms |
461848 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |