# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
630541 |
2022-08-16T13:39:18 Z |
CSQ31 |
Catfish Farm (IOI22_fish) |
C++17 |
|
539 ms |
365424 KB |
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int f[3001][3001];
ll dp[2][3001][3001];
//0 -> previous is lower
//1 -> previous is higher
const ll INF = -1e17;
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]++;
f[X[i]][Y[i]] = W[i];
}
for(int i=0;i<=n;i++){
for(int j=0;j<=n;j++)dp[0][i][j] = dp[1][i][j] = INF;
}
dp[0][0][0] = 0;
for(int i=1;i<=n;i++){
ll mx = INF;
ll sum = 0;
for(int j=0;j<=n;j++){
sum+=f[i-1][j];
mx = max(mx,dp[0][i-1][j] - sum);
dp[0][i][j] = max(dp[0][i][j],mx+sum);
}
mx = INF;
sum = 0;
for(int j=0;j<=n;j++)sum+=f[i][j];
for(int j=n;j>=0;j--){
mx = max(dp[0][i-1][j]+sum,mx);
mx = max(dp[1][i-1][j]+sum,mx);
dp[1][i][j] = max(dp[1][i][j],mx - sum);
sum-=f[i][j];
}
if(i>=2){
sum = 0;
mx = INF;
for(int j=0;j<=n;j++){
sum+=f[i-1][j];
mx = max(mx,dp[0][i-2][j]);
mx = max(mx,dp[1][i-2][j]);
dp[0][i][j] = max(dp[0][i][j],mx+sum);
}
}
}
ll ans = 0;
for(int i=0;i<=n;i++){
ans = max(ans,dp[0][n][i]);
ans = max(ans,dp[1][n][i]);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
505 ms |
361616 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Runtime error |
521 ms |
365424 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
539 ms |
357664 KB |
Execution killed with signal 11 |
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 |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
2 ms |
2388 KB |
Output is correct |
10 |
Correct |
4 ms |
5332 KB |
Output is correct |
11 |
Correct |
1 ms |
2388 KB |
Output is correct |
12 |
Correct |
3 ms |
5332 KB |
Output is correct |
13 |
Correct |
1 ms |
1236 KB |
Output is correct |
14 |
Correct |
3 ms |
5332 KB |
Output is correct |
# |
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 |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
2 ms |
2388 KB |
Output is correct |
10 |
Correct |
4 ms |
5332 KB |
Output is correct |
11 |
Correct |
1 ms |
2388 KB |
Output is correct |
12 |
Correct |
3 ms |
5332 KB |
Output is correct |
13 |
Correct |
1 ms |
1236 KB |
Output is correct |
14 |
Correct |
3 ms |
5332 KB |
Output is correct |
15 |
Correct |
3 ms |
5332 KB |
Output is correct |
16 |
Correct |
1 ms |
1236 KB |
Output is correct |
17 |
Correct |
15 ms |
6228 KB |
Output is correct |
18 |
Correct |
20 ms |
5960 KB |
Output is correct |
19 |
Correct |
19 ms |
6524 KB |
Output is correct |
20 |
Correct |
15 ms |
6592 KB |
Output is correct |
21 |
Correct |
15 ms |
6480 KB |
Output is correct |
22 |
Correct |
32 ms |
7768 KB |
Output is correct |
23 |
Correct |
8 ms |
5844 KB |
Output is correct |
24 |
Correct |
12 ms |
6356 KB |
Output is correct |
25 |
Correct |
3 ms |
5332 KB |
Output is correct |
26 |
Correct |
5 ms |
5716 KB |
Output is correct |
# |
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 |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
2 ms |
2388 KB |
Output is correct |
10 |
Correct |
4 ms |
5332 KB |
Output is correct |
11 |
Correct |
1 ms |
2388 KB |
Output is correct |
12 |
Correct |
3 ms |
5332 KB |
Output is correct |
13 |
Correct |
1 ms |
1236 KB |
Output is correct |
14 |
Correct |
3 ms |
5332 KB |
Output is correct |
15 |
Correct |
3 ms |
5332 KB |
Output is correct |
16 |
Correct |
1 ms |
1236 KB |
Output is correct |
17 |
Correct |
15 ms |
6228 KB |
Output is correct |
18 |
Correct |
20 ms |
5960 KB |
Output is correct |
19 |
Correct |
19 ms |
6524 KB |
Output is correct |
20 |
Correct |
15 ms |
6592 KB |
Output is correct |
21 |
Correct |
15 ms |
6480 KB |
Output is correct |
22 |
Correct |
32 ms |
7768 KB |
Output is correct |
23 |
Correct |
8 ms |
5844 KB |
Output is correct |
24 |
Correct |
12 ms |
6356 KB |
Output is correct |
25 |
Correct |
3 ms |
5332 KB |
Output is correct |
26 |
Correct |
5 ms |
5716 KB |
Output is correct |
27 |
Correct |
125 ms |
153416 KB |
Output is correct |
28 |
Correct |
77 ms |
22680 KB |
Output is correct |
29 |
Correct |
201 ms |
149876 KB |
Output is correct |
30 |
Correct |
245 ms |
177116 KB |
Output is correct |
31 |
Correct |
233 ms |
177532 KB |
Output is correct |
32 |
Correct |
95 ms |
19820 KB |
Output is correct |
33 |
Correct |
257 ms |
183532 KB |
Output is correct |
34 |
Correct |
241 ms |
183580 KB |
Output is correct |
35 |
Correct |
156 ms |
157528 KB |
Output is correct |
36 |
Correct |
223 ms |
158780 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
539 ms |
357664 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
505 ms |
361616 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |