답안 #1069430

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1069430 2024-08-21T22:14:13 Z MarwenElarbi 메기 농장 (IOI22_fish) C++17
0 / 100
977 ms 2097152 KB
#include <bits/stdc++.h>
#include "fish.h"
using namespace std;

long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,
                          std::vector<int> W) {
    int n=N;
    int m=M;
    int grid[n][n];
    memset(grid,0,sizeof grid);
    long long pre[n][n];
    for (int i = 0; i < m; ++i)
    {
        grid[X[i]][Y[i]]=W[i];
    }
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            pre[i][j]=(j ? pre[i][j-1] : 0)+grid[i][j];
        }
    }
    long long dp[n][n][2];
    memset(dp,0,sizeof dp);
    long long ans=0;
    for (int i = 1; i < n; ++i)
    {
        for (int j = 0; j < n; ++j)
        {
            for (int k = 0; k < n; ++k)
            {
                if(k<j){
                    dp[i][j][1]=max(dp[i][j][1],dp[i-1][k][1]+pre[i-1][j]-(k ? pre[i-1][k-1] : 0));
                }else if(k>j){
                    dp[i][j][0]=max(dp[i][j][0],dp[i-1][k][1]+pre[i][k]-(j ? pre[i][j-1] : 0));
                    dp[i][j][0]=max(dp[i][j][0],dp[i-1][k][0]+pre[i][k]-(j ? pre[i][j-1] : 0));
                }else if (j==0){
                    dp[i][j][0]=max({dp[i][j][0],dp[i-1][j][0],dp[i-1][j][1]});
                    dp[i][j][1]=max({dp[i][j][1],dp[i-1][j][0],dp[i-1][j][1]});
                }else{
                    dp[i][j][0]=max({dp[i][j][0],dp[i-1][j][0],dp[i-1][j][1]});
                    dp[i][j][1]=max(dp[i][j][1],dp[i-1][j][1]);
                }
            }
            ans=max({ans,dp[i][j][0],dp[i][j][1]});

        }
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 977 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Runtime error 974 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 964 ms 2097152 KB Execution killed with signal 9
2 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 10 ms 1068 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '218332757910'
10 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 10 ms 1068 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '218332757910'
10 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 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 10 ms 1068 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '218332757910'
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 964 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 977 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -