답안 #1079099

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1079099 2024-08-28T10:48:12 Z ArthuroWich 메기 농장 (IOI22_fish) C++17
0 / 100
956 ms 2097152 KB
#include "fish.h"
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int max_weights(int32_t N, int32_t M, vector<int32_t> X, vector<int32_t> Y, vector<int32_t> W) {
    int n = N, m = M;
    vector<vector<int>> c(n+1, vector<int>(n+1, 0));
    vector<vector<vector<int>>> dp(n+1, vector<vector<int>>(n+1, vector<int>(2, 0)));
    for (int i = 0; i < m; i++) {
        c[X[i]][Y[i]] = W[i];
    }
    int i = 0;
    for (int j = 0; j < n; j++) {
        if (j-1 >= 0) {
            dp[i][j][0] = max(dp[i][j][0], dp[i][j-1][1]+c[i][j]);
            dp[i][j][0] = max(dp[i][j][0], dp[i][j-1][0]);
            dp[i][j][1] = max(dp[i][j][1], dp[i][j-1][0]);
            dp[i][j][1] = max(dp[i][j][1], dp[i][j-1][1]);
        }
        if (j == 1) {
            dp[i][j][1] = max(dp[i][j][1], dp[i][j-1][0]+c[i][j-1]);
        }
        if (j-1 >= 0) {
            dp[i][j][1] = max(dp[i][j][1], dp[i][j-2][0]+c[i][j-2]);
            dp[i][j][1] = max(dp[i][j][1], dp[i][j-2][1]+c[i][j-2]);
        }
    }
    return max(dp[n-1][n-1][0], dp[n-1][n-1][1]);
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 956 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '2', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 858 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 858 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 956 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -