Submission #1023077

# Submission time Handle Problem Language Result Execution time Memory
1023077 2024-07-14T09:20:20 Z vjudge1 Catfish Farm (IOI22_fish) C++17
32 / 100
1000 ms 88848 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 15 ms 2176 KB Output is correct
2 Correct 25 ms 4436 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 62 ms 13648 KB Output is correct
6 Correct 62 ms 13908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 30 ms 4928 KB Output is correct
3 Correct 39 ms 9296 KB Output is correct
4 Correct 16 ms 3668 KB Output is correct
5 Correct 20 ms 4432 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 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 4272 KB Output is correct
13 Correct 32 ms 5196 KB Output is correct
14 Correct 16 ms 4432 KB Output is correct
15 Correct 24 ms 4688 KB Output is correct
16 Correct 15 ms 4696 KB Output is correct
17 Correct 17 ms 4696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 35 ms 78596 KB Output is correct
3 Correct 46 ms 77016 KB Output is correct
4 Correct 50 ms 84092 KB Output is correct
5 Correct 56 ms 88660 KB Output is correct
6 Correct 59 ms 88660 KB Output is correct
7 Correct 55 ms 88848 KB Output is correct
8 Correct 56 ms 88680 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 0 ms 348 KB Output is correct
6 Correct 1 ms 600 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 344 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 604 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 0 ms 348 KB Output is correct
6 Correct 1 ms 600 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 344 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Execution timed out 1026 ms 344 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 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 1 ms 600 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 344 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Execution timed out 1026 ms 344 KB Time limit exceeded
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 35 ms 78596 KB Output is correct
3 Correct 46 ms 77016 KB Output is correct
4 Correct 50 ms 84092 KB Output is correct
5 Correct 56 ms 88660 KB Output is correct
6 Correct 59 ms 88660 KB Output is correct
7 Correct 55 ms 88848 KB Output is correct
8 Correct 56 ms 88680 KB Output is correct
9 Runtime error 21 ms 5460 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 2176 KB Output is correct
2 Correct 25 ms 4436 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 62 ms 13648 KB Output is correct
6 Correct 62 ms 13908 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 30 ms 4928 KB Output is correct
9 Correct 39 ms 9296 KB Output is correct
10 Correct 16 ms 3668 KB Output is correct
11 Correct 20 ms 4432 KB Output is correct
12 Correct 1 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 1 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 4272 KB Output is correct
19 Correct 32 ms 5196 KB Output is correct
20 Correct 16 ms 4432 KB Output is correct
21 Correct 24 ms 4688 KB Output is correct
22 Correct 15 ms 4696 KB Output is correct
23 Correct 17 ms 4696 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 35 ms 78596 KB Output is correct
26 Correct 46 ms 77016 KB Output is correct
27 Correct 50 ms 84092 KB Output is correct
28 Correct 56 ms 88660 KB Output is correct
29 Correct 59 ms 88660 KB Output is correct
30 Correct 55 ms 88848 KB Output is correct
31 Correct 56 ms 88680 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 600 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 1 ms 344 KB Output is correct
41 Correct 1 ms 600 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 1 ms 604 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 604 KB Output is correct
46 Execution timed out 1026 ms 344 KB Time limit exceeded
47 Halted 0 ms 0 KB -