#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
ll max_weights(int n, int m, vector<int> X, vector<int> Y, vector<int> W){
vector<vector<ll>> v(n, vector<ll>(n+1, 0));
for(int i = 0; i < m; i++) v[X[i]][Y[i]+1]+=W[i];
vector<vector<ll>> dp_up(n, vector<ll>(n+1, 0)), dp_down = dp_up;
for(int i = n-1; i >= 0; i--) for(int j = 0; j <= n; j++){
if(i == n-1){
dp_down[i][j] = 0;
dp_up[i][j] = 0;
continue;
}
ll s = 0;
for(int k = j; k <= n; k++){
if(k > j) s+=v[i][k];
dp_up[i][j] = max(dp_up[i][j], s+dp_up[i+1][k]);
}
s = 0;
for(int k = j; k >= 0; k--){
if(k < j) s+=v[i+1][k+1];
dp_down[i][j] = max(dp_down[i][j], s+dp_down[i+1][k]);
}
s = 0;
for(int k = j+1; k <= n; k++) s+=v[i][k];
dp_up[i][j] = max(dp_up[i][j], s+dp_down[i+1][n]);
if(i+2 < n){
s = 0;
for(int k = 0; k <= j; k++) s+=v[i+1][k];
for(int k = 0; k <= n; k++){
if(k > j) s+=v[i+1][k];
//dp_down[i][j] = max(dp_down[i][j], s+dp_up[i+2][k]);
}
dp_down[i][j] = max(dp_down[i][j], s+dp_down[i+2][n]);
}
}
return max(*max_element(dp_up[0].begin(), dp_up[0].end()), *max_element(dp_down[0].begin(), dp_down[0].end()));
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
717 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
300 KB |
Output is correct |
2 |
Runtime error |
731 ms |
2097152 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
703 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
304 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
300 KB |
Output is correct |
9 |
Correct |
11 ms |
852 KB |
Output is correct |
10 |
Correct |
73 ms |
2540 KB |
Output is correct |
11 |
Incorrect |
10 ms |
852 KB |
1st lines differ - on the 1st token, expected: '278622587073', found: '277471986209' |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
304 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
300 KB |
Output is correct |
9 |
Correct |
11 ms |
852 KB |
Output is correct |
10 |
Correct |
73 ms |
2540 KB |
Output is correct |
11 |
Incorrect |
10 ms |
852 KB |
1st lines differ - on the 1st token, expected: '278622587073', found: '277471986209' |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
304 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
300 KB |
Output is correct |
9 |
Correct |
11 ms |
852 KB |
Output is correct |
10 |
Correct |
73 ms |
2540 KB |
Output is correct |
11 |
Incorrect |
10 ms |
852 KB |
1st lines differ - on the 1st token, expected: '278622587073', found: '277471986209' |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
703 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
717 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |