#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vll = vector<ll>;
ll max_weights(int n, int m, vi X, vi Y, vi W) {
int maxy = 0;
for(int i = 0; i < m; ++i) {
++Y[i];
maxy = max(maxy, Y[i]);
}
vector<vector<ll> > C(n, vll(maxy + 1, 0));
for(int i = 0; i < m; ++i) {
C[X[i]][Y[i]] = W[i];
}
const ll INF = 1e18;
vector<vector<vll> > DP(n + 1, vector(maxy + 1, vll(maxy + 1, -INF)));
DP[0][0][0] = 0;
ll re = 0;
for(int i = 0; i < n; ++i) {
for(int h2 = 0; h2 <= maxy; ++h2) {
for(int h1 = 0; h1 <= maxy; ++h1) {
ll cost0 = 0;
for(int j = 0; j <= maxy; ++j) {
if(j <= h1) cost0 += C[i][j];
}
if(!i) cost0 = 0;
for(int h = 0; h <= maxy; ++h) {
ll cnou = 0;
for(int j = 0; j <= maxy; ++j) {
if(j > h && j <= h1) cnou += C[i][j];
if(j <= h && i + 1 < n) cnou += C[i + 1][j];
if(j <= h && j > h1 && j > h2 && i) cnou += C[i - 1][j];
}
DP[i + 1][h1][h] = max(DP[i + 1][h1][h], DP[i][h2][h1] + cnou - cost0);
re = max(re, DP[i + 1][h1][h]);
}
}
}
}
return re;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
933 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
877 ms |
2097152 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
20568 KB |
Output is correct |
2 |
Correct |
29 ms |
20568 KB |
Output is correct |
3 |
Correct |
43 ms |
20900 KB |
Output is correct |
4 |
Correct |
32 ms |
22108 KB |
Output is correct |
5 |
Correct |
42 ms |
24636 KB |
Output is correct |
6 |
Correct |
52 ms |
23892 KB |
Output is correct |
7 |
Correct |
43 ms |
24400 KB |
Output is correct |
8 |
Correct |
39 ms |
24656 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
5 ms |
600 KB |
Output is correct |
11 |
Correct |
3 ms |
604 KB |
Output is correct |
12 |
Correct |
5 ms |
804 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
5 ms |
600 KB |
Output is correct |
11 |
Correct |
3 ms |
604 KB |
Output is correct |
12 |
Correct |
5 ms |
804 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
604 KB |
Output is correct |
15 |
Execution timed out |
1065 ms |
217268 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
5 ms |
600 KB |
Output is correct |
11 |
Correct |
3 ms |
604 KB |
Output is correct |
12 |
Correct |
5 ms |
804 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
2 ms |
604 KB |
Output is correct |
15 |
Execution timed out |
1065 ms |
217268 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
20568 KB |
Output is correct |
2 |
Correct |
29 ms |
20568 KB |
Output is correct |
3 |
Correct |
43 ms |
20900 KB |
Output is correct |
4 |
Correct |
32 ms |
22108 KB |
Output is correct |
5 |
Correct |
42 ms |
24636 KB |
Output is correct |
6 |
Correct |
52 ms |
23892 KB |
Output is correct |
7 |
Correct |
43 ms |
24400 KB |
Output is correct |
8 |
Correct |
39 ms |
24656 KB |
Output is correct |
9 |
Runtime error |
894 ms |
2097152 KB |
Execution killed with signal 9 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
933 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |