Submission #713261

# Submission time Handle Problem Language Result Execution time Memory
713261 2023-03-21T14:49:28 Z t6twotwo Catfish Farm (IOI22_fish) C++17
0 / 100
1000 ms 2097152 KB
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;
long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
    vector w(N + 1, vector<int64_t>(N + 1));
    for (int i = 0; i < M; i++) {
        w[X[i]][Y[i] + 1] = W[i];
    }
    for (int i = 0; i < N; i++) {
        for (int j = 1; j <= N; j++) {
            w[i][j + 1] += w[i][j];
        }
    }
    vector dp1(N + 1, vector<int64_t>(N));
    for (int i = 1; i <= N; i++) {
        for (int j = 0; j < N; j++) {
            for (int k = 0; k <= j; k++) {
                dp1[i][j] = max(dp1[i][j], dp1[i - 1][k] + (k == j ? 0 : w[i - 1][j] - w[i - 1][k + 1]));
            }
        }
    }
    vector dp2(N + 1, vector<int64_t>(N));
    for (int i = N - 1; i >= 0; i--) {
        for (int j = 0; j < N; j++) {
            for (int k = 0; k <= j; k++) {
                dp2[i][j] = max(dp2[i][j], dp2[i + 1][k] + (k == j ? 0 : w[i + 1][j] - w[i + 1][k + 1]));
            }
        }
    }
    int64_t ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            ans = max(ans, dp1[i + 1][j] + dp2[i][j]);
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1167 ms 1798364 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 892 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 892 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1167 ms 1798364 KB Time limit exceeded
2 Halted 0 ms 0 KB -