Submission #1076239

# Submission time Handle Problem Language Result Execution time Memory
1076239 2024-08-26T12:06:27 Z vjudge1 Catfish Farm (IOI22_fish) C++17
0 / 100
851 ms 2097152 KB
#include "fish.h"

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vi = vector<int>;
using ii = pair<int, int>;
using vll = vector<ll>;

ll max_weights(int n, int m, vi X, vi Y, vi W) {
    int maxy = 0;
    for(int i = 0; i < m; ++i) {
        maxy = max(maxy, Y[i]);
    }
    vector<vector<ll> > C(n, vll(maxy + 1, 0));
    for(int i = 0; i < m; ++i) {
        C[X[i]][Y[i]] = W[i];
    }

    const ll INF = 1e9;
    vector<vector<vll> > DP(n + 1, vector(maxy + 1, vll(maxy + 1, -INF)));
    DP[0][0][0] = 0;
    ll re = 0;
    for(int i = 0; i < n; ++i) {
        for(int h2 = 0; h2 <= maxy; ++h2) {
            for(int h1 = 0; h1 <= maxy; ++h1) {
                ll cost0 = 0;
                for(int j = 0; j <= maxy; ++j) {
                    if(j <= h1) cost0 += C[i][j];
                }

                for(int h = 0; h <= maxy; ++h) {
                    ll cnou = 0;
                    for(int j = 0; j <= maxy; ++j) {
                        if(j > h && j <= h1) cnou += C[i][j];
                        if(j <= h && i + 1 < n) cnou += C[i + 1][j];
                        if(j <= h && j > h1 && j > h2 && i) cnou += C[i - 1][j];
                    }
                    DP[i + 1][h1][h] = max(DP[i + 1][h1][h], DP[i][h2][h1] + cnou - cost0);
                    re = max(re, DP[i + 1][h1][h]);
                }
            }
        }
    }
    return re;
}
# Verdict Execution time Memory Grader output
1 Runtime error 851 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '2', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 14428 KB 1st lines differ - on the 1st token, expected: '10082010', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 14428 KB 1st lines differ - on the 1st token, expected: '10082010', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 851 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -