답안 #1056461

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1056461 2024-08-13T09:33:01 Z aykhn 메기 농장 (IOI22_fish) C++17
0 / 100
103 ms 16980 KB
#include "fish.h"
#include <bits/stdc++.h>

using namespace std;

const int MXN = 3e2 + 5;

long long dp[2][MXN][MXN], val[MXN][MXN];
long long lft[MXN][MXN], rig[MXN][MXN], in[MXN][MXN];

/*
0 = len[i] < len[i + 1];
1 = len[i] > len[i + 1];
*/
long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) 
{
    #define int long long
    for (int i = 0; i < M; i++) val[X[i] + 1][Y[i] + 1] = 1LL * val[X[i] + 1][Y[i] + 1] + 1LL * W[i];
    for (int i = 1; i <= N; i++) 
    {
        for (int j = 1; j <= N; j++)
        {
            lft[i][j] = lft[i][j - 1] + val[i - 1][j];
            rig[i][j] = rig[i][j - 1] + val[i + 1][j];
            in[i][j] = in[i][j - 1] + val[i][j];
        }
    }
    for (int i = 1; i <= N; i++)
    {
        for (int j = 1; j <= N; j++)
        {
            dp[0][i][j] = dp[1][i][j] = lft[i][j] + rig[i][j];
            if (i == 1) continue;
            for (int k = 1; k <= N; k++)
            {
                if (k <= j)
                {
                    long long res = (dp[0][i - 1][k] - rig[i - 1][k]) + ((lft[i][j] - in[i - 1][k]) + rig[i][j]);
                    dp[0][i][j] = max(dp[0][i][j], res);
                }
                if (k >= j)
                {
                    long long res = dp[1][i - 1][k] - in[i][j] + rig[i][j];
                    dp[1][i][j] = max(dp[1][i][j], res);
                }
            }
            if (i == 2) continue;
            for (int k = 1; k <= N; k++)
            {
                long long res = max(dp[0][i - 2][k], dp[1][i - 2][k]) + lft[i][j] + rig[i][j];
                if (k <= j) res -= rig[i - 2][k];
                else res -= lft[i][j];
                dp[0][i][j] = max(dp[0][i][j], res);
                dp[1][i][j] = max(dp[1][i][j], res);
            }
        }
    }
    long long ans = 0;
    for (int i = 1; i <= N; i++) 
    {
        for (int j = 1; j <= N; j++) 
        {
            ans = max({ans, dp[0][i][j], dp[1][i][j]});
        }
    }
    return ans;
    #undef int
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 77 ms 13024 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Runtime error 103 ms 16980 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 71 ms 7884 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 0 ms 4444 KB Output is correct
3 Correct 0 ms 4444 KB Output is correct
4 Correct 0 ms 4444 KB Output is correct
5 Correct 0 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 0 ms 4444 KB Output is correct
9 Incorrect 11 ms 4700 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '197515751547'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 0 ms 4444 KB Output is correct
3 Correct 0 ms 4444 KB Output is correct
4 Correct 0 ms 4444 KB Output is correct
5 Correct 0 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 0 ms 4444 KB Output is correct
9 Incorrect 11 ms 4700 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '197515751547'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4444 KB Output is correct
2 Correct 0 ms 4444 KB Output is correct
3 Correct 0 ms 4444 KB Output is correct
4 Correct 0 ms 4444 KB Output is correct
5 Correct 0 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 0 ms 4444 KB Output is correct
9 Incorrect 11 ms 4700 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '197515751547'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 71 ms 7884 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 77 ms 13024 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -