# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1023078 |
2024-07-14T09:20:43 Z |
mansur |
Catfish Farm (IOI22_fish) |
C++17 |
|
1000 ms |
88700 KB |
#include "fish.h"
#include<bits/stdc++.h>
using namespace std;
#define rall(s) s.rbegin(), s.rend()
#define all(s) s.begin(), s.end()
#define sz(s) (int)s.size()
#define s second
#define f first
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int N = 1e5 + 5;
const ll inf = 1e18;
ll c[N][10], dp[N][10][10];
long long max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w) {
int z = 0, ok1 = 1, ok2 = 1;
ll sm = 0;;
for (int i = 0; i < m; i++) {
if (x[i] & 1) ok1 = 0;
if (x[i] > 1) ok2 = 0;
sm += w[i];
}
if (ok1) return sm;
if (ok2) {
if (n == 2) {
ll sum[2];
sum[0] = sum[1] = 0;
for (int i = 0; i < m; i++) {
sum[x[i]] += w[i];
}
return max(sum[0], sum[1]);
}
int vl[2][n + 1];
memset(vl, 0, sizeof(vl));
sm = 0;
for (int i = 0; i < m; i++) {
vl[x[i]][y[i]] = w[i];
if (x[i]) sm += w[i];
}
ll ans = 0;
for (int i = 0; i <= n; i++) {
ans = max(ans, sm);
sm -= vl[1][i];
sm += vl[0][i];
}
return ans;
}
for (int i = 0; i < m; i++) {
c[x[i] + 1][y[i] + 1] = w[i];
z = max(z, y[i] + 2);
}
for (int j = 0; j < z; j++) {
for (int k = 0; k < z; k++) {
dp[0][j][k] = (k ? -inf : 0);
}
}
for (int i = 1; i <= n; i++) {
for (int j = 0; j < z; j++) {
for (int k = 0; k < z; k++) {
for (int s = 0; s < z; s++) {
ll sum = 0;
for (int x = k + 1; x <= max(j, s); x++) {
sum += c[i][x];
}
dp[i][j][k] = max(dp[i][j][k], dp[i - 1][k][s] + sum);
}
}
}
}
ll ans = 0;
for (int i = 0; i < z; i++) {
ans = max(ans, dp[n][0][i]);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
2136 KB |
Output is correct |
2 |
Correct |
17 ms |
2652 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
54 ms |
7296 KB |
Output is correct |
6 |
Correct |
55 ms |
7248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
31 ms |
4956 KB |
Output is correct |
3 |
Correct |
37 ms |
5876 KB |
Output is correct |
4 |
Correct |
15 ms |
2140 KB |
Output is correct |
5 |
Correct |
18 ms |
2652 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
344 KB |
Output is correct |
10 |
Correct |
1 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
16 ms |
2952 KB |
Output is correct |
13 |
Correct |
20 ms |
3424 KB |
Output is correct |
14 |
Correct |
16 ms |
2904 KB |
Output is correct |
15 |
Correct |
17 ms |
3164 KB |
Output is correct |
16 |
Correct |
16 ms |
2908 KB |
Output is correct |
17 |
Correct |
17 ms |
3160 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
37 ms |
78676 KB |
Output is correct |
3 |
Correct |
46 ms |
76884 KB |
Output is correct |
4 |
Correct |
44 ms |
84172 KB |
Output is correct |
5 |
Correct |
69 ms |
88660 KB |
Output is correct |
6 |
Correct |
53 ms |
88656 KB |
Output is correct |
7 |
Correct |
54 ms |
88672 KB |
Output is correct |
8 |
Correct |
55 ms |
88700 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 |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 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 |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
856 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
736 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 |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 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 |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
856 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
736 KB |
Output is correct |
15 |
Execution timed out |
1052 ms |
348 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 |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 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 |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
1 ms |
856 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
736 KB |
Output is correct |
15 |
Execution timed out |
1052 ms |
348 KB |
Time limit exceeded |
16 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
37 ms |
78676 KB |
Output is correct |
3 |
Correct |
46 ms |
76884 KB |
Output is correct |
4 |
Correct |
44 ms |
84172 KB |
Output is correct |
5 |
Correct |
69 ms |
88660 KB |
Output is correct |
6 |
Correct |
53 ms |
88656 KB |
Output is correct |
7 |
Correct |
54 ms |
88672 KB |
Output is correct |
8 |
Correct |
55 ms |
88700 KB |
Output is correct |
9 |
Runtime error |
23 ms |
5464 KB |
Execution killed with signal 11 |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
2136 KB |
Output is correct |
2 |
Correct |
17 ms |
2652 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
54 ms |
7296 KB |
Output is correct |
6 |
Correct |
55 ms |
7248 KB |
Output is correct |
7 |
Correct |
0 ms |
344 KB |
Output is correct |
8 |
Correct |
31 ms |
4956 KB |
Output is correct |
9 |
Correct |
37 ms |
5876 KB |
Output is correct |
10 |
Correct |
15 ms |
2140 KB |
Output is correct |
11 |
Correct |
18 ms |
2652 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
348 KB |
Output is correct |
18 |
Correct |
16 ms |
2952 KB |
Output is correct |
19 |
Correct |
20 ms |
3424 KB |
Output is correct |
20 |
Correct |
16 ms |
2904 KB |
Output is correct |
21 |
Correct |
17 ms |
3164 KB |
Output is correct |
22 |
Correct |
16 ms |
2908 KB |
Output is correct |
23 |
Correct |
17 ms |
3160 KB |
Output is correct |
24 |
Correct |
1 ms |
344 KB |
Output is correct |
25 |
Correct |
37 ms |
78676 KB |
Output is correct |
26 |
Correct |
46 ms |
76884 KB |
Output is correct |
27 |
Correct |
44 ms |
84172 KB |
Output is correct |
28 |
Correct |
69 ms |
88660 KB |
Output is correct |
29 |
Correct |
53 ms |
88656 KB |
Output is correct |
30 |
Correct |
54 ms |
88672 KB |
Output is correct |
31 |
Correct |
55 ms |
88700 KB |
Output is correct |
32 |
Correct |
0 ms |
348 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
1 ms |
348 KB |
Output is correct |
35 |
Correct |
1 ms |
348 KB |
Output is correct |
36 |
Correct |
0 ms |
348 KB |
Output is correct |
37 |
Correct |
0 ms |
348 KB |
Output is correct |
38 |
Correct |
1 ms |
348 KB |
Output is correct |
39 |
Correct |
0 ms |
348 KB |
Output is correct |
40 |
Correct |
1 ms |
348 KB |
Output is correct |
41 |
Correct |
1 ms |
604 KB |
Output is correct |
42 |
Correct |
1 ms |
348 KB |
Output is correct |
43 |
Correct |
1 ms |
856 KB |
Output is correct |
44 |
Correct |
0 ms |
348 KB |
Output is correct |
45 |
Correct |
1 ms |
736 KB |
Output is correct |
46 |
Execution timed out |
1052 ms |
348 KB |
Time limit exceeded |
47 |
Halted |
0 ms |
0 KB |
- |