답안 #1079173

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1079173 2024-08-28T11:40:17 Z ArthuroWich 메기 농장 (IOI22_fish) C++17
0 / 100
49 ms 38232 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(9, vector<int>(n+1, 0));
    vector<vector<int>> dp(9, vector<int>(n+1, 0));
    for (int i = 0; i < m; i++) {
        c[Y[i]][X[i]] = W[i];
    }
    for (int j = 1; j < n; j++) {
        int v = 0;
        dp[0][j] = max(dp[0][j], dp[0][j-1]);
        for (int i = 1; i < 9; i++) {
            v += c[i-1][j];
            dp[0][j] = max(dp[0][j-1], dp[i][j-1]+v);
        }
        for (int i = 1; i < 9; i++) {
            for (int a = i; a < 9; a++) {
                v = 0;
                for (int b = i+1; b <= a; b++) {
                    v += c[b-1][j];
                }
                dp[i][j] = max(dp[i][j], dp[a][j-1]+v);
            } 
        }
        if (j == 1) {
            v = 0;
            for (int i = 1; i < 9; i++) {
                v += c[i-1][j-1];
                dp[i][j] = max(dp[i][j], dp[0][j-1]+v);
            }
        }
        if (j-2 >= 0) {
            v = 0;
            for (int i = 1; i < 9; i++) {
                v += c[i-1][j-1];
                dp[i][j] = max(dp[i][j], dp[0][j-2]+v);
            }
            for (int i = 1; i < 9; i++) {
                v = 0;
                for (int h = 0; h < i; h++) {
                    v += c[h][j-1];
                }
                for (int h = 1; h <= i; h++) {
                    dp[i][j] = max(dp[i][j], dp[h][j-1]+v);
                }
                for (int h = i+1; h < 9; h++) {
                    v += c[h-1][j];
                    dp[i][j] = max(dp[i][j], dp[h][j-1]+v);
                }
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < 9; i++) {
        ans = max(ans, dp[i][n-1]);
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 35 ms 32912 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Runtime error 49 ms 38232 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 15180 KB Output is correct
2 Correct 24 ms 15344 KB Output is correct
3 Incorrect 37 ms 16028 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '26722970331638'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 15180 KB Output is correct
2 Correct 24 ms 15344 KB Output is correct
3 Incorrect 37 ms 16028 KB 1st lines differ - on the 1st token, expected: '21261825233649', found: '26722970331638'
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 35 ms 32912 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -