Submission #1075024

# Submission time Handle Problem Language Result Execution time Memory
1075024 2024-08-25T17:41:55 Z Zicrus Catfish Farm (IOI22_fish) C++17
23 / 100
340 ms 264864 KB
#include <bits/stdc++.h>
#include "fish.h"
using namespace std;
    
typedef long long ll;
    
int n, m;
vector<int> x, y, w;
    
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
    n = N; m = M; x = X; y = Y; w = W;
    int q = min(n, 8+1);
    vector<vector<ll>> a(n, vector<ll>(q));
    for (int i = 0; i < m; i++) {
        a[x[i]][y[i]] = w[i];
    }
    vector<vector<ll>> sum(n, vector<ll>(q+1));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < q; j++) {
            sum[i][j+1] = sum[i][j] + a[i][j];
        }
    }

    vector<vector<vector<ll>>> dp(n, vector<vector<ll>>(q+1, vector<ll>(q+1)));
    for (int i = 1; i < n; i++) {
        for (int j = 0; j <= q; j++) {
            for (int j1 = 0; j1 <= q; j1++) {
                for (int k = 0; k <= q; k++) {
                    ll val = dp[i-1][j1][k];
                    if (j1 > j) val += sum[i][j1] - sum[i][j];
                    if (j > max(j1, k)) val += sum[i-1][j] - sum[i-1][max(j1, k)];
                    dp[i][j][j1] = max(dp[i][j][j1], val);
                }
            }
        }
    }

    ll res = 0;
    for (int j = 0; j <= q; j++) {
        for (int j1 = 0; j1 <= q; j1++) {
            res = max(res, dp[n-1][j][j1]);
        }
    }
    for (int i = n-2; i >= n-5 && i >= 0; i--) {
        for (int j = 0; j <= q; j++) {
            for (int j1 = 0; j1 <= q; j1++) {
                ll val = dp[i][j][j1] + sum[i+1][j];
                res = max(res, val);
            }
        }
    }
    return res;
}
    
#ifdef TEST
#include "grader.cpp"
#endif
# Verdict Execution time Memory Grader output
1 Runtime error 340 ms 259040 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 334 ms 264864 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 265 ms 143624 KB Output is correct
2 Correct 278 ms 143676 KB Output is correct
3 Correct 243 ms 131264 KB Output is correct
4 Correct 252 ms 144932 KB Output is correct
5 Correct 284 ms 147212 KB Output is correct
6 Correct 273 ms 147020 KB Output is correct
7 Correct 279 ms 147028 KB Output is correct
8 Correct 271 ms 148560 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 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 1 ms 604 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 856 KB Output is correct
12 Correct 1 ms 860 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 860 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 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 1 ms 604 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 856 KB Output is correct
12 Correct 1 ms 860 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 860 KB Output is correct
15 Runtime error 2 ms 1372 KB Execution killed with signal 6
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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 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 1 ms 604 KB Output is correct
10 Correct 1 ms 860 KB Output is correct
11 Correct 1 ms 856 KB Output is correct
12 Correct 1 ms 860 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 860 KB Output is correct
15 Runtime error 2 ms 1372 KB Execution killed with signal 6
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 265 ms 143624 KB Output is correct
2 Correct 278 ms 143676 KB Output is correct
3 Correct 243 ms 131264 KB Output is correct
4 Correct 252 ms 144932 KB Output is correct
5 Correct 284 ms 147212 KB Output is correct
6 Correct 273 ms 147020 KB Output is correct
7 Correct 279 ms 147028 KB Output is correct
8 Correct 271 ms 148560 KB Output is correct
9 Runtime error 32 ms 29532 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 340 ms 259040 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -