#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
long long max_weights(int n,int m,vector<int>x,vector<int>y,vector<int>w){
long long dp[n+2][n+2][2]{};
int sum[n+2][n+2]{};
for(int i = 0; i < m; i++) x[i] += 1;
for(int i = 0; i < m; i++) y[i] += 1;
for(int i = 0; i < m; i++) sum[x[i]][y[i]] += w[i];
long long ans = 0;
for(int i = 1; i <= n+1; i++){
for(int j = 0; j < 2; j++){
dp[0][i][j] = -1e18;
}
}
dp[0][0][1] = 0;
for(int i = 1; i <= n; i++){
for(int j = 0; j <= n+1; j++){
for(int k = 0; k <= n+1; k++){
long long now = dp[i-1][j][1];
int cur = k;
while(cur > j) now += sum[i-1][cur--];
cur = j;
while(cur > k) now += sum[i][cur--];
if(k >= j) dp[i][k][1] = max(dp[i][k][1],now);
else dp[i][k][0] = max(dp[i][k][0],now);
ans = max(ans,now);
}
for(int k = 0; k < j; k++){
long long now = dp[i-1][j][0];
int cur = j;
while(cur > k) now += sum[i][cur--];
dp[i][k][0] = max(dp[i][k][0],now);
ans = max(ans,now);
}
}
}
return ans;
}
// int main(){
// cout << max_weights(5, 4, {0, 1, 4, 3}, {2, 1, 4, 3}, {5, 2, 1, 3}) << '\n';
// }
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1164 ms |
1935864 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Execution timed out |
1105 ms |
2097152 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1037 ms |
2097152 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
352 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
352 KB |
Output is correct |
5 |
Correct |
0 ms |
352 KB |
Output is correct |
6 |
Correct |
0 ms |
352 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
165 ms |
880 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '7581483960' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
352 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
352 KB |
Output is correct |
5 |
Correct |
0 ms |
352 KB |
Output is correct |
6 |
Correct |
0 ms |
352 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
165 ms |
880 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '7581483960' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
352 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
352 KB |
Output is correct |
5 |
Correct |
0 ms |
352 KB |
Output is correct |
6 |
Correct |
0 ms |
352 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Incorrect |
165 ms |
880 KB |
1st lines differ - on the 1st token, expected: '216624184325', found: '7581483960' |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1037 ms |
2097152 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1164 ms |
1935864 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |