Submission #1069421

# Submission time Handle Problem Language Result Execution time Memory
1069421 2024-08-21T21:54:48 Z MarwenElarbi Catfish Farm (IOI22_fish) C++17
0 / 100
1000 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]});
                }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;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1022 ms 2097152 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Execution timed out 1039 ms 2097152 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 998 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 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 344 KB Output is correct
6 Correct 0 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 Incorrect 11 ms 1068 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '12943675734'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 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 344 KB Output is correct
6 Correct 0 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 Incorrect 11 ms 1068 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '12943675734'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 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 344 KB Output is correct
6 Correct 0 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 Incorrect 11 ms 1068 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '12943675734'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 998 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1022 ms 2097152 KB Time limit exceeded
2 Halted 0 ms 0 KB -