#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
#define scd(t) scanf("%d", &t)
#define sclld(t) scanf("%lld", &t)
#define forr(i, j, k) for (int i = j; i < k; i++)
#define frange(i, j) forr(i, 0, j)
#define all(cont) cont.begin(), cont.end()
#define mp make_pair
#define pb push_back
#define f first
#define s second
typedef long long int lli;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<lli> vll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mpii;
typedef set<int> seti;
typedef multiset<int> mseti;
typedef long double ld;
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;
vector<vll> grid(n, vll(n+1));
frange(i, m) {
grid[X[i]][Y[i]+1] = W[i];
}
vector<vll> dp1(n, vll(n+1)), dp2(n, vll(n+1));
forr(i, 1, n+1) {
dp2[0][i] = grid[0][i];
dp2[0][i] += dp2[0][i-1];
}
forr(i, 1, n) {
frange(j, n+1) {
dp1[i][j] = dp2[i-1][j];
lli v = 0;
forr(k, j+1, n+1) {
v += grid[i][k];
dp1[i][j] = max(dp1[i][j], dp1[i-1][k] + v);
}
v = 0;
for(int k=j; k>=0; k--) {
dp2[i][j] = max(dp2[i][j], dp2[i-1][k] + v);
v += grid[i][k];
}
frange(k, n+1) {
dp2[i][j] = max(dp2[i][j], dp1[i-1][k] + v);
}
}
}
return *max_element(all(dp1[n-1]));
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
825 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 |
825 ms |
2097152 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
789 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 |
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 |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
5 ms |
860 KB |
Output is correct |
10 |
Correct |
39 ms |
2652 KB |
Output is correct |
11 |
Correct |
7 ms |
860 KB |
Output is correct |
12 |
Correct |
43 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
39 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
5 ms |
860 KB |
Output is correct |
10 |
Correct |
39 ms |
2652 KB |
Output is correct |
11 |
Correct |
7 ms |
860 KB |
Output is correct |
12 |
Correct |
43 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
39 ms |
2396 KB |
Output is correct |
15 |
Correct |
42 ms |
2396 KB |
Output is correct |
16 |
Correct |
2 ms |
604 KB |
Output is correct |
17 |
Correct |
47 ms |
4432 KB |
Output is correct |
18 |
Correct |
46 ms |
4188 KB |
Output is correct |
19 |
Correct |
47 ms |
4188 KB |
Output is correct |
20 |
Correct |
46 ms |
4188 KB |
Output is correct |
21 |
Correct |
51 ms |
4368 KB |
Output is correct |
22 |
Correct |
64 ms |
5968 KB |
Output is correct |
23 |
Correct |
42 ms |
2908 KB |
Output is correct |
24 |
Correct |
44 ms |
3672 KB |
Output is correct |
25 |
Correct |
39 ms |
2392 KB |
Output is correct |
26 |
Correct |
41 ms |
2920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 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 |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
5 ms |
860 KB |
Output is correct |
10 |
Correct |
39 ms |
2652 KB |
Output is correct |
11 |
Correct |
7 ms |
860 KB |
Output is correct |
12 |
Correct |
43 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
39 ms |
2396 KB |
Output is correct |
15 |
Correct |
42 ms |
2396 KB |
Output is correct |
16 |
Correct |
2 ms |
604 KB |
Output is correct |
17 |
Correct |
47 ms |
4432 KB |
Output is correct |
18 |
Correct |
46 ms |
4188 KB |
Output is correct |
19 |
Correct |
47 ms |
4188 KB |
Output is correct |
20 |
Correct |
46 ms |
4188 KB |
Output is correct |
21 |
Correct |
51 ms |
4368 KB |
Output is correct |
22 |
Correct |
64 ms |
5968 KB |
Output is correct |
23 |
Correct |
42 ms |
2908 KB |
Output is correct |
24 |
Correct |
44 ms |
3672 KB |
Output is correct |
25 |
Correct |
39 ms |
2392 KB |
Output is correct |
26 |
Correct |
41 ms |
2920 KB |
Output is correct |
27 |
Execution timed out |
1105 ms |
212056 KB |
Time limit exceeded |
28 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
789 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
825 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |