# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
838748 |
2023-08-27T16:37:43 Z |
Andrey |
Catfish Farm (IOI22_fish) |
C++17 |
|
318 ms |
404920 KB |
#include "fish.h"
#include<bits/stdc++.h>
#include <vector>
using namespace std;
long long haha[5000][5000];
long long dp[3001][3001][3];
long long max_weights(int n, int m, std::vector<int> x, std::vector<int> y, std::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]][y[i]+1] = w[i];
}
for(long long i = 0; i < n; i++) {
for(long long j = 1; j <= n; j++) {
haha[i][j]+=haha[i][j-1];
}
}
for(long long i = 0; i <= n; i++) {
for(long long j = 0; j <= n; j++) {
dp[i][j][0] = 0;
dp[i][j][1] = 0;
dp[i][j][2] = 0;
}
}
for(int i = 0; i <= n; i++) {
dp[0][i][0] = haha[1][i];
}
long long ans = 0,sb;
for(long long i = 1; i < n; i++) {
sb = 0;
for(long long j = 0; j <= n; j++) {
dp[i][j][2] = max(dp[i][j][2],dp[i-1][j][0]);
dp[i][j][2] = max(dp[i][j][2],dp[i-1][j][1]);
sb = max(sb,dp[i-1][j][2]);
}
long long big = 0;
for(long long j = 0; j <= n; j++) {
big = max(big,dp[i-1][j][0]-haha[i-1][j]-haha[i][j]);
dp[i][j][0] = big+haha[i+1][j]+haha[i-1][j];
}
big = 0;
for(long long j = n; j >= 0; j--) {
dp[i][j][1] = big-haha[i][j]+haha[i+1][j];
big = max(big,dp[i-1][j][0]);
}
big = 0;
for(long long j = n; j >= 0; j--) {
dp[i][j][1] = max(dp[i][j][1],big-haha[i][j]+haha[i+1][j]);
big = max(big,dp[i-1][j][1]);
}
big = 0;
for(long long j = 0; j <= n; j++) {
dp[i][j][0] = max(dp[i][j][0],sb+haha[i+1][j]);
big = max(big,dp[i-1][j][2]-haha[i-1][j]);
dp[i][j][0] = max(dp[i][j][0],big+haha[i-1][j]);
}
}
for(long long i = 0; i <= n; i++) {
ans = max(ans,dp[n-1][i][0]);
ans = max(ans,dp[n-1][i][1]);
ans = max(ans,dp[n-1][i][2]);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
318 ms |
400964 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 |
316 ms |
404920 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
286 ms |
397120 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 |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
2260 KB |
Output is correct |
10 |
Correct |
3 ms |
5588 KB |
Output is correct |
11 |
Correct |
1 ms |
2260 KB |
Output is correct |
12 |
Correct |
4 ms |
5648 KB |
Output is correct |
13 |
Correct |
1 ms |
1108 KB |
Output is correct |
14 |
Correct |
3 ms |
5588 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 |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
2260 KB |
Output is correct |
10 |
Correct |
3 ms |
5588 KB |
Output is correct |
11 |
Correct |
1 ms |
2260 KB |
Output is correct |
12 |
Correct |
4 ms |
5648 KB |
Output is correct |
13 |
Correct |
1 ms |
1108 KB |
Output is correct |
14 |
Correct |
3 ms |
5588 KB |
Output is correct |
15 |
Correct |
3 ms |
5588 KB |
Output is correct |
16 |
Correct |
1 ms |
1108 KB |
Output is correct |
17 |
Correct |
12 ms |
6612 KB |
Output is correct |
18 |
Correct |
20 ms |
6608 KB |
Output is correct |
19 |
Correct |
13 ms |
6608 KB |
Output is correct |
20 |
Correct |
12 ms |
6600 KB |
Output is correct |
21 |
Correct |
13 ms |
6600 KB |
Output is correct |
22 |
Correct |
28 ms |
7620 KB |
Output is correct |
23 |
Correct |
5 ms |
5716 KB |
Output is correct |
24 |
Correct |
9 ms |
6284 KB |
Output is correct |
25 |
Correct |
3 ms |
5588 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 |
0 ms |
340 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
2260 KB |
Output is correct |
10 |
Correct |
3 ms |
5588 KB |
Output is correct |
11 |
Correct |
1 ms |
2260 KB |
Output is correct |
12 |
Correct |
4 ms |
5648 KB |
Output is correct |
13 |
Correct |
1 ms |
1108 KB |
Output is correct |
14 |
Correct |
3 ms |
5588 KB |
Output is correct |
15 |
Correct |
3 ms |
5588 KB |
Output is correct |
16 |
Correct |
1 ms |
1108 KB |
Output is correct |
17 |
Correct |
12 ms |
6612 KB |
Output is correct |
18 |
Correct |
20 ms |
6608 KB |
Output is correct |
19 |
Correct |
13 ms |
6608 KB |
Output is correct |
20 |
Correct |
12 ms |
6600 KB |
Output is correct |
21 |
Correct |
13 ms |
6600 KB |
Output is correct |
22 |
Correct |
28 ms |
7620 KB |
Output is correct |
23 |
Correct |
5 ms |
5716 KB |
Output is correct |
24 |
Correct |
9 ms |
6284 KB |
Output is correct |
25 |
Correct |
3 ms |
5588 KB |
Output is correct |
26 |
Correct |
5 ms |
5716 KB |
Output is correct |
27 |
Correct |
195 ms |
294388 KB |
Output is correct |
28 |
Correct |
63 ms |
32252 KB |
Output is correct |
29 |
Correct |
269 ms |
306904 KB |
Output is correct |
30 |
Correct |
271 ms |
307012 KB |
Output is correct |
31 |
Correct |
295 ms |
307012 KB |
Output is correct |
32 |
Correct |
80 ms |
26200 KB |
Output is correct |
33 |
Correct |
260 ms |
307004 KB |
Output is correct |
34 |
Correct |
275 ms |
306976 KB |
Output is correct |
35 |
Correct |
217 ms |
299076 KB |
Output is correct |
36 |
Correct |
268 ms |
306916 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
286 ms |
397120 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
318 ms |
400964 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |