#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define ll long long
#define vi vector<int>
#define ii pair<int, int>
#define vii vector<ii>
const int N = 1e5+5, inf = INT_MAX;
int n, m;
int c[10][N];
bitset<N> vis[10][10];
ll dp[10][10][N]; // dp[i][j][k] = maximos peces que puedo conseguir
// con las k primeras columnas donde
// en la columna k+1 he subido i-1
// en la columna k+2 he subido j-1
ll mx(int curr, int h1, int h2) {
if (curr == -1) return 0;
if (vis[h1][h2][curr]) return dp[h1][h2][curr];
dp[h1][h2][curr] = 0;
vis[h1][h2][curr] = 1;
for (int h = 0; h < min(10, n+1); h++) {
ll cnt = 0;
// ver si pillo los de la derecha
if (curr+1 < n) {
for (int i = 0; i < h; i++) {
if (h2-1 < i && h1-1 < i) cnt += c[i][curr+1];
}
}
// ver si pillo los de la izquierda
if (curr-1 >= 0) {
for (int i = 0; i < h; i++) {
cnt += c[i][curr-1];
}
}
// ver si he eliminado alguno de los que he pillado
for (int i = 0; i < min(h, h1); i++) {
cnt -= c[i][curr];
}
dp[h1][h2][curr] = max(dp[h1][h2][curr], cnt + mx(curr-1, h, h1));
}
return dp[h1][h2][curr];
}
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
std::vector<int> W) {
for (int i = 0; i < 10; i++) {
memset(c[i], 0, sizeof(c[i]));
}
n = N;
m = M;
for (int i = 0; i < m; i++) {
c[Y[i]][X[i]] = W[i];
}
return mx(n-1, 0, 0);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
38 ms |
12084 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
4308 KB |
Output is correct |
2 |
Runtime error |
56 ms |
16036 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1085 ms |
53148 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4436 KB |
Output is correct |
2 |
Correct |
2 ms |
4948 KB |
Output is correct |
3 |
Correct |
2 ms |
4180 KB |
Output is correct |
4 |
Correct |
3 ms |
4180 KB |
Output is correct |
5 |
Correct |
2 ms |
4180 KB |
Output is correct |
6 |
Correct |
2 ms |
4180 KB |
Output is correct |
7 |
Correct |
2 ms |
4308 KB |
Output is correct |
8 |
Correct |
2 ms |
4308 KB |
Output is correct |
9 |
Correct |
6 ms |
5204 KB |
Output is correct |
10 |
Correct |
9 ms |
5460 KB |
Output is correct |
11 |
Correct |
6 ms |
5204 KB |
Output is correct |
12 |
Correct |
9 ms |
5460 KB |
Output is correct |
13 |
Correct |
4 ms |
5204 KB |
Output is correct |
14 |
Correct |
10 ms |
5380 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4436 KB |
Output is correct |
2 |
Correct |
2 ms |
4948 KB |
Output is correct |
3 |
Correct |
2 ms |
4180 KB |
Output is correct |
4 |
Correct |
3 ms |
4180 KB |
Output is correct |
5 |
Correct |
2 ms |
4180 KB |
Output is correct |
6 |
Correct |
2 ms |
4180 KB |
Output is correct |
7 |
Correct |
2 ms |
4308 KB |
Output is correct |
8 |
Correct |
2 ms |
4308 KB |
Output is correct |
9 |
Correct |
6 ms |
5204 KB |
Output is correct |
10 |
Correct |
9 ms |
5460 KB |
Output is correct |
11 |
Correct |
6 ms |
5204 KB |
Output is correct |
12 |
Correct |
9 ms |
5460 KB |
Output is correct |
13 |
Correct |
4 ms |
5204 KB |
Output is correct |
14 |
Correct |
10 ms |
5380 KB |
Output is correct |
15 |
Runtime error |
9 ms |
8288 KB |
Execution killed with signal 11 |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
4436 KB |
Output is correct |
2 |
Correct |
2 ms |
4948 KB |
Output is correct |
3 |
Correct |
2 ms |
4180 KB |
Output is correct |
4 |
Correct |
3 ms |
4180 KB |
Output is correct |
5 |
Correct |
2 ms |
4180 KB |
Output is correct |
6 |
Correct |
2 ms |
4180 KB |
Output is correct |
7 |
Correct |
2 ms |
4308 KB |
Output is correct |
8 |
Correct |
2 ms |
4308 KB |
Output is correct |
9 |
Correct |
6 ms |
5204 KB |
Output is correct |
10 |
Correct |
9 ms |
5460 KB |
Output is correct |
11 |
Correct |
6 ms |
5204 KB |
Output is correct |
12 |
Correct |
9 ms |
5460 KB |
Output is correct |
13 |
Correct |
4 ms |
5204 KB |
Output is correct |
14 |
Correct |
10 ms |
5380 KB |
Output is correct |
15 |
Runtime error |
9 ms |
8288 KB |
Execution killed with signal 11 |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1085 ms |
53148 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
38 ms |
12084 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |