#include <bits/stdc++.h>
//#include "fish.h"
using namespace std;
#define pb push_back
#define mp make_pair
long long dp[3005][3005][2]; //col,height,increasing/decreasing
long long pre[3005][3005];
long long max_weights(int n,int m,vector<int> x,vector<int> y,vector<int> w){
for (int i=0;i<m;i++){
x[i]++;
y[i]++;
pre[x[i]][y[i]]=w[i];
}
for (int i=1;i<=n;i++){
for (int j=1;j<=n;j++){
pre[i][j]+=pre[i][j-1];
}
}
for (int i=1;i<=n;i++){ //col
for (int j=0;j<=n;j++){ //col height
dp[i][j][0]=-1e18;
dp[i][j][1]=-1e18;
}
long long maxi=0;
for (int j=0;j<=n;j++){
//calculate increasing
maxi=max(maxi,dp[i-1][j][0]-pre[i][j]-pre[i-1][j]);
/*
for (int k=0;k<=j;k++){ //prev col height
dp[i][j][0]=max(dp[i][j][0],dp[i-1][k][0]-pre[i][k]-pre[i-1][k]);
}
*/
if (i>=2){
//i-1 col height is 0
for (int k=0;k<=n;k++){ //i-2 col height
dp[i][j][0]=max(dp[i][j][0],dp[i-2][k][1]-pre[i-1][min(k,j)]);
}
}
dp[i][j][0]=maxi+pre[i-1][j]+pre[i+1][j];
}
for (int j=0;j<=n;j++){
//calculate decreasing
for (int k=j;k<=n;k++){ //prev col height
dp[i][j][1]=max(dp[i][j][1],dp[i-1][k][1]);
}
dp[i][j][1]+=pre[i+1][j]-pre[i][j];
}
for (int j=0;j<=n;j++){
dp[i][j][1]=max(dp[i][j][1],dp[i][j][0]);
}
}
long long ans=0;
for (int j=0;j<=n;j++){
ans=max(ans,dp[n][j][1]);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1094 ms |
119084 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Execution timed out |
1095 ms |
118900 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1094 ms |
108256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Incorrect |
8 ms |
2016 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '7818664569' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Incorrect |
8 ms |
2016 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '7818664569' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Incorrect |
8 ms |
2016 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '7818664569' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1094 ms |
108256 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1094 ms |
119084 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |