# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
625719 |
2022-08-10T17:27:45 Z |
d4xn |
Catfish Farm (IOI22_fish) |
C++17 |
|
1000 ms |
56084 KB |
#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 = 301, inf = INT_MAX;
int n, m;
int c[N][N];
bitset<N> vis[N][N];
ll dp[N][N][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 < 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 < N; 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);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
26 ms |
4976 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 |
49 ms |
8864 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
1108 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 |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
360 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Execution timed out |
1101 ms |
56084 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
360 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Execution timed out |
1101 ms |
56084 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
360 KB |
Output is correct |
4 |
Correct |
0 ms |
340 KB |
Output is correct |
5 |
Correct |
0 ms |
340 KB |
Output is correct |
6 |
Correct |
0 ms |
340 KB |
Output is correct |
7 |
Correct |
0 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Execution timed out |
1101 ms |
56084 KB |
Time limit exceeded |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
1108 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
26 ms |
4976 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |