#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll a[3001][3001], b[3001][3001], d[3001][3001];
int n, m;
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) {
n = N; m = M;
for (int i = 0; i < m; i++) d[Y[i] + 1][X[i] + 1] = W[i];
for (int j = 1; j <= n; j++) {
if (j != n) {
a[1][j] = b[1][j - 1] + d[1][j];
for (int i = 2; i <= n; i++) a[i][j] = max(a[i - 1][j] , a[i - 1][j - 1]) + d[i][j];
}
if (j == 1) continue;
b[n][j] = max(a[n][j - 2] , b[1][j - 2]) + d[n][j];
for (int i = n - 1; i > 0; i--) b[i][j] = max(b[i + 1][j] , b[i + 1][j - 1]) + d[i][j];
}
ll ans = max(a[n][n - 1] , b[1][n]);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
23 ms |
4184 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2396 KB |
Output is correct |
2 |
Runtime error |
44 ms |
8236 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
73 ms |
142668 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2512 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
2 ms |
8796 KB |
Output is correct |
10 |
Correct |
3 ms |
19240 KB |
Output is correct |
11 |
Correct |
3 ms |
10844 KB |
Output is correct |
12 |
Correct |
3 ms |
19292 KB |
Output is correct |
13 |
Correct |
1 ms |
6748 KB |
Output is correct |
14 |
Correct |
3 ms |
17244 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2512 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
2 ms |
8796 KB |
Output is correct |
10 |
Correct |
3 ms |
19240 KB |
Output is correct |
11 |
Correct |
3 ms |
10844 KB |
Output is correct |
12 |
Correct |
3 ms |
19292 KB |
Output is correct |
13 |
Correct |
1 ms |
6748 KB |
Output is correct |
14 |
Correct |
3 ms |
17244 KB |
Output is correct |
15 |
Correct |
4 ms |
25436 KB |
Output is correct |
16 |
Correct |
3 ms |
8796 KB |
Output is correct |
17 |
Correct |
13 ms |
26460 KB |
Output is correct |
18 |
Correct |
12 ms |
26588 KB |
Output is correct |
19 |
Correct |
12 ms |
26460 KB |
Output is correct |
20 |
Correct |
13 ms |
26456 KB |
Output is correct |
21 |
Correct |
13 ms |
22348 KB |
Output is correct |
22 |
Correct |
21 ms |
27628 KB |
Output is correct |
23 |
Correct |
5 ms |
25692 KB |
Output is correct |
24 |
Correct |
10 ms |
26200 KB |
Output is correct |
25 |
Correct |
3 ms |
19292 KB |
Output is correct |
26 |
Correct |
5 ms |
23388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2512 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
2 ms |
8796 KB |
Output is correct |
10 |
Correct |
3 ms |
19240 KB |
Output is correct |
11 |
Correct |
3 ms |
10844 KB |
Output is correct |
12 |
Correct |
3 ms |
19292 KB |
Output is correct |
13 |
Correct |
1 ms |
6748 KB |
Output is correct |
14 |
Correct |
3 ms |
17244 KB |
Output is correct |
15 |
Correct |
4 ms |
25436 KB |
Output is correct |
16 |
Correct |
3 ms |
8796 KB |
Output is correct |
17 |
Correct |
13 ms |
26460 KB |
Output is correct |
18 |
Correct |
12 ms |
26588 KB |
Output is correct |
19 |
Correct |
12 ms |
26460 KB |
Output is correct |
20 |
Correct |
13 ms |
26456 KB |
Output is correct |
21 |
Correct |
13 ms |
22348 KB |
Output is correct |
22 |
Correct |
21 ms |
27628 KB |
Output is correct |
23 |
Correct |
5 ms |
25692 KB |
Output is correct |
24 |
Correct |
10 ms |
26200 KB |
Output is correct |
25 |
Correct |
3 ms |
19292 KB |
Output is correct |
26 |
Correct |
5 ms |
23388 KB |
Output is correct |
27 |
Correct |
143 ms |
211796 KB |
Output is correct |
28 |
Correct |
56 ms |
65300 KB |
Output is correct |
29 |
Correct |
195 ms |
224340 KB |
Output is correct |
30 |
Correct |
198 ms |
224328 KB |
Output is correct |
31 |
Correct |
200 ms |
224444 KB |
Output is correct |
32 |
Correct |
68 ms |
53996 KB |
Output is correct |
33 |
Correct |
195 ms |
224340 KB |
Output is correct |
34 |
Correct |
198 ms |
224532 KB |
Output is correct |
35 |
Correct |
122 ms |
150352 KB |
Output is correct |
36 |
Correct |
187 ms |
187364 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
73 ms |
142668 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
23 ms |
4184 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |