답안 #1079345

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1079345 2024-08-28T13:18:07 Z ArthuroWich 메기 농장 (IOI22_fish) C++17
23 / 100
177 ms 139992 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, yn;
    yn = 9;
    vector<vector<int>> c(yn+1, vector<int>(n+1, 0));
    vector<vector<vector<int>>> dp(yn+1, vector<vector<int>>(n+1, vector<int>(2, 0))); // 0 is increasing, 1 is decreasing, increasing can go to decreasing, decreasing cant go to increasing if next to eachother
    for (int i = 0; i < m; i++) {
        c[Y[i]+1][X[i]] = W[i];
    }
    for (int j = 1; j < n; j++) {
        int v = 0;
        dp[0][j][0] = max(dp[0][j][0], dp[0][j-1][0]);
        for (int i = 1; i <= yn; i++) {
            v += c[i][j];
            dp[0][j][0] = max(dp[0][j][0], dp[i][j-1][0]+v);
            dp[0][j][0] = max(dp[0][j][0], dp[i][j-1][1]+v);
        }
        for (int i = 1; i <= yn; i++) {
            for (int a = i; a <= yn; a++) {
                v = 0;
                for (int b = i+1; b <= a; b++) {
                    v += c[b][j];
                }
                dp[i][j][1] = max(dp[i][j][1], dp[a][j-1][0]+v);
                dp[i][j][1] = max(dp[i][j][1], dp[a][j-1][1]+v);
            } 
            for (int a = 1; a <= i; a++) {
                v = 0;
                for (int b = a+1; b <= i; b++) {
                    v += c[b][j-1];
                }
                dp[i][j][0] = max(dp[i][j][0], dp[a][j-1][0]+v);
            } 
        }
        if (j == 1) {
            v = 0;
            for (int i = 1; i <= yn; i++) {
                v += c[i][j-1];
                dp[i][j][0] = max(dp[i][j][0], dp[0][j-1][0]+v);
                dp[i][j][1] = max(dp[i][j][1], dp[0][j-1][0]+v);
            }
        }
        if (j-2 >= 0) {
            v = 0;
            for (int i = 1; i <= yn; i++) {
                v += c[i][j-1];
                dp[i][j][0] = max(dp[i][j][0], dp[0][j-2][0]+v);
                dp[i][j][1] = max(dp[i][j][1], dp[0][j-2][0]+v);
            }
            for (int i = 1; i <= yn; i++) {
                v = 0;
                for (int h = 1; h <= i; h++) {
                    v += c[h][j-1];
                }
                for (int h = 1; h <= i; h++) {
                    dp[i][j][0] = max(dp[i][j][0], dp[h][j-2][0]+v);
                    dp[i][j][0] = max(dp[i][j][0], dp[h][j-2][1]+v);
                    dp[i][j][1] = max(dp[i][j][1], dp[h][j-2][0]+v);
                    dp[i][j][1] = max(dp[i][j][1], dp[h][j-2][1]+v);
                }
                for (int h = i+1; h < yn; h++) {
                    v += c[h][j-1];
                    dp[i][j][0] = max(dp[i][j][0], dp[h][j-2][0]+v);
                    dp[i][j][0] = max(dp[i][j][0], dp[h][j-2][1]+v);
                    dp[i][j][1] = max(dp[i][j][1], dp[h][j-2][0]+v);
                    dp[i][j][1] = max(dp[i][j][1], dp[h][j-2][1]+v);
                }
            }
        }
    }
    int ans = 0;
    for (int i = 0; i <= yn; i++) {
        ans = max(ans, dp[i][n-1][0]);
        ans = max(ans, dp[i][n-1][1]);
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 105 ms 125780 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 177 ms 130492 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 113 ms 68400 KB Output is correct
2 Correct 118 ms 68332 KB Output is correct
3 Correct 144 ms 63888 KB Output is correct
4 Correct 121 ms 69996 KB Output is correct
5 Correct 132 ms 72260 KB Output is correct
6 Correct 165 ms 71800 KB Output is correct
7 Correct 143 ms 72344 KB Output is correct
8 Correct 132 ms 72256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 488 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 488 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Runtime error 1 ms 860 KB Execution killed with signal 11
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 488 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Runtime error 1 ms 860 KB Execution killed with signal 11
16 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 113 ms 68400 KB Output is correct
2 Correct 118 ms 68332 KB Output is correct
3 Correct 144 ms 63888 KB Output is correct
4 Correct 121 ms 69996 KB Output is correct
5 Correct 132 ms 72260 KB Output is correct
6 Correct 165 ms 71800 KB Output is correct
7 Correct 143 ms 72344 KB Output is correct
8 Correct 132 ms 72256 KB Output is correct
9 Runtime error 109 ms 139992 KB Execution killed with signal 11
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 105 ms 125780 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -