답안 #969597

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
969597 2024-04-25T10:44:40 Z vjudge1 메기 농장 (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, std::vector<int> X, std::vector<int> Y,
                      std::vector<int> W) {
    vector<vector<int64_t>> pref(N, vector<int64_t>(N + 1));
    vector<vector<int>> a(N, vector<int>(N));

    for (int i = 0; i < M; i++) {
        a[X[i]][Y[i]] = W[i];
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) pref[i][j + 1] = pref[i][j] + a[i][j];
    }
    const int64_t inf = 1e18;
    vector<vector<int64_t>> dp(N + 1, vector<int64_t>(2, -inf));
    dp[0][0] = 0;
    for (int i = 0; i < N; i++) {
        vector<vector<int64_t>> ndp(N + 1, vector<int64_t>(2, -inf));
        for (int j = 0; j < N; j++) {
            dp[j + 1][0] = max(dp[j + 1][0], dp[j][0] + a[i][j]);
        }
        for (int j = N - 1; j > 0; j--) {
            dp[j - 1][1] = max(dp[j - 1][1], dp[j][1] + a[i][j - 1]);
        }
        dp[0][0] = max(dp[0][0], dp[0][1]);
        if (i == N - 1) break;
        for (int j = 0; j <= N; j++) {
            ndp[j][0] = max(ndp[j][0], dp[j][0]);
            if (j == N) ndp[N][1] = max(ndp[N][1], dp[j][0]);
        }
        for (int j = 0; j <= N; j++) {
            ndp[j][1] = max(ndp[j][1], dp[j][1]);
            if (j == N) ndp[N - 1][1] = max(ndp[N - 1][1], dp[j][1] + a[i + 1][N - 1]);
            if (j == 0) ndp[0][0] = max(ndp[0][0], dp[j][1]);
        }
        ndp.swap(dp);
    }
    return max(dp[0][1], dp[N][1]);
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1186 ms 1917180 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Runtime error 829 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 762 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 432 KB 1st lines differ - on the 1st token, expected: '4044', found: '2022'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 432 KB 1st lines differ - on the 1st token, expected: '4044', found: '2022'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Incorrect 1 ms 432 KB 1st lines differ - on the 1st token, expected: '4044', found: '2022'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 762 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1186 ms 1917180 KB Time limit exceeded
2 Halted 0 ms 0 KB -