Submission #991832

# Submission time Handle Problem Language Result Execution time Memory
991832 2024-06-03T08:26:41 Z thinknoexit Catfish Farm (IOI22_fish) C++17
67 / 100
982 ms 2097152 KB
#include <bits/stdc++.h>
#include "fish.h"
using namespace std;
using ll = long long;
int n, m;
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
    n = N, m = M;
    int r = 0, c = 0;
    for (int i = 0;i < m;i++) {
        r = max(r, X[i] + 1);
        c = max(c, Y[i] + 1);
    }
    c++;
    r = min(n, r + 1);
    vector<vector<int>> a(r + 1, vector<int>(c + 1, 0));
    vector<vector<vector<ll>>> dp(3, vector<vector<ll>>(r + 1, vector<ll>(c + 1, 0ll)));
    for (int i = 0;i < m;i++) {
        a[X[i] + 1][Y[i] + 1] = W[i];
    }
    ll mx;
    for (int i = 2;i <= r;i++) {
        // (0)
        mx = 0;
        for (int j = 0;j <= c;j++) {
            mx = max({ mx + a[i - 1][j], dp[0][i - 1][j], dp[2][i - 1][j] });
            dp[0][i][j] = mx;
        }
        mx = 0;
        for (int j = c;j >= 0;j--) {
            mx = max(mx, dp[2][i - 1][j]);
            dp[0][i][j] = max(dp[0][i][j], mx);
        }
        // (1)
        mx = 0;
        for (int j = c;j >= 0;j--) {
            dp[1][i][j] = mx;
            mx = max({ mx + a[i][j], dp[0][i - 1][j], dp[1][i - 1][j] });
        }
        // (2)
        mx = 0;
        for (int j = 0;j <= c;j++) {
            mx += a[i][j];
            dp[2][i][j] = max(dp[0][i - 1][j], dp[1][i - 1][j]) + mx;
        }
    }
    ll ans = 0;
    for (int i = 1;i <= r;i++) {
        for (int j = 0;j <= c;j++) {
            ans = max(ans, dp[0][i][j]);
            ans = max(ans, dp[1][i][j]);
            ans = max(ans, dp[2][i][j]);
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 26 ms 12540 KB Output is correct
2 Correct 24 ms 14028 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 6 ms 11732 KB Output is correct
5 Runtime error 982 ms 2097152 KB Execution killed with signal 9
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 36 ms 17648 KB Output is correct
3 Correct 47 ms 19916 KB Output is correct
4 Correct 19 ms 12556 KB Output is correct
5 Correct 25 ms 14024 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 6 ms 11732 KB Output is correct
12 Correct 23 ms 15644 KB Output is correct
13 Correct 27 ms 17608 KB Output is correct
14 Correct 24 ms 15600 KB Output is correct
15 Correct 29 ms 17292 KB Output is correct
16 Correct 22 ms 15604 KB Output is correct
17 Correct 26 ms 17240 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 31 ms 27592 KB Output is correct
3 Correct 34 ms 25948 KB Output is correct
4 Correct 31 ms 25800 KB Output is correct
5 Correct 50 ms 30032 KB Output is correct
6 Correct 44 ms 30036 KB Output is correct
7 Correct 44 ms 30044 KB Output is correct
8 Correct 45 ms 30036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 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 0 ms 348 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 620 KB Output is correct
13 Correct 0 ms 436 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 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 0 ms 348 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 620 KB Output is correct
13 Correct 0 ms 436 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 3 ms 3672 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 14 ms 5448 KB Output is correct
18 Correct 15 ms 5464 KB Output is correct
19 Correct 10 ms 5468 KB Output is correct
20 Correct 10 ms 5468 KB Output is correct
21 Correct 10 ms 3676 KB Output is correct
22 Correct 20 ms 7248 KB Output is correct
23 Correct 4 ms 3932 KB Output is correct
24 Correct 9 ms 4836 KB Output is correct
25 Correct 1 ms 600 KB Output is correct
26 Correct 4 ms 3932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 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 0 ms 348 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 620 KB Output is correct
13 Correct 0 ms 436 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 3 ms 3672 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 14 ms 5448 KB Output is correct
18 Correct 15 ms 5464 KB Output is correct
19 Correct 10 ms 5468 KB Output is correct
20 Correct 10 ms 5468 KB Output is correct
21 Correct 10 ms 3676 KB Output is correct
22 Correct 20 ms 7248 KB Output is correct
23 Correct 4 ms 3932 KB Output is correct
24 Correct 9 ms 4836 KB Output is correct
25 Correct 1 ms 600 KB Output is correct
26 Correct 4 ms 3932 KB Output is correct
27 Correct 226 ms 318292 KB Output is correct
28 Correct 51 ms 28496 KB Output is correct
29 Correct 252 ms 280288 KB Output is correct
30 Correct 289 ms 329812 KB Output is correct
31 Correct 279 ms 329808 KB Output is correct
32 Correct 62 ms 22100 KB Output is correct
33 Correct 297 ms 329808 KB Output is correct
34 Correct 291 ms 329828 KB Output is correct
35 Correct 33 ms 22364 KB Output is correct
36 Correct 161 ms 133712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 31 ms 27592 KB Output is correct
3 Correct 34 ms 25948 KB Output is correct
4 Correct 31 ms 25800 KB Output is correct
5 Correct 50 ms 30032 KB Output is correct
6 Correct 44 ms 30036 KB Output is correct
7 Correct 44 ms 30044 KB Output is correct
8 Correct 45 ms 30036 KB Output is correct
9 Runtime error 894 ms 2097152 KB Execution killed with signal 9
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 26 ms 12540 KB Output is correct
2 Correct 24 ms 14028 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 6 ms 11732 KB Output is correct
5 Runtime error 982 ms 2097152 KB Execution killed with signal 9
6 Halted 0 ms 0 KB -