#include "fish.h"
#include<bits/stdc++.h>
using namespace std;
long long haha[5001][5001];
long long dp[5001][5001][2];
long long max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w) {
for(long long i = 0; i <= n; i++) {
for(long long j = 0; j <= n; j++) {
haha[i][j] = 0;
}
}
for(long long i = 0; i < m; i++) {
haha[x[i]+1][y[i]+1] = w[i];
}
for(long long i = 0; i <= n; i++) {
dp[0][i][0] = -LLONG_MAX/2;
dp[0][i][1] = -LLONG_MAX/2;
}
dp[0][0][0] = 0;
for(long long i = 1; i <= n; i++) {
long long br = 0;
for(long long j = 0; j <= n; j++) {
br+=haha[i][j];
long long sb1 = 0;
dp[i][j][1] = max(dp[i][j][1],dp[i-1][j][0]+br);
for(int k = 0; k <= n; k++) {
if(k > j) {
sb1+=haha[i-1][k];
}
dp[i][k][0] = max(dp[i][k][0],dp[i-1][j][0]+sb1);
dp[i][k][0] = max(dp[i][k][0],dp[i-1][j][1]+sb1);
}
}
}
long long ans = 0;
for(long long i = 0; i <= n; i++) {
ans = max(ans,max(dp[n][i][0],dp[n][i][1]));
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
217 ms |
324180 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Runtime error |
246 ms |
327460 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
214 ms |
320848 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
344 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 |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
344 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 |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
344 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 |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
9 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
214 ms |
320848 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
217 ms |
324180 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |