Submission #993506

# Submission time Handle Problem Language Result Execution time Memory
993506 2024-06-05T21:12:32 Z cpdreamer Catfish Farm (IOI22_fish) C++17
0 / 100
878 ms 2097152 KB
#include "fish.h"

#include <bits/stdc++.h>
using namespace std;
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,std::vector<int> W) {
    vector<vector<int>> grid(N+1, vector<int>(N + 1));
    for (int i = 0; i <= N; i++)
        grid[i].assign(N + 1, 0);
    long long  dp[N][N + 1][N + 1];
    long long  vp[N][N + 1][N + 1];
    for (int i = 0; i < M; i++) {
        grid[X[i] ][Y[i]+1] += W[i];
    }
    for (int i = 0; i <=N; i++) {
        for (int j = 1; j <= N; j++) {
            grid[i][j] += grid[i][j - 1];
        }
    }
    for (int i = 0; i <=N; i++) {
        for (int j = 0; j <= N; j++) {
            dp[0][i][j] = max(0, grid[0][j] - grid[0][i]);
            if (i > 0)
                vp[0][i][j] = max(vp[0][i - 1][j], dp[0][i][j]+max(0,grid[1][i]-grid[1][j]));
            else
                vp[0][i][j] = dp[0][i][j]+max(0,grid[1][i]-grid[1][j]);
        }
    }
    for (int i = 1; i < N; i++) {
        for (int j = 0; j <= N; j++) {
            for (int g = 0; g <= N; g++) {
                if(g>j){
                    dp[i][j][g]=grid[i][g]-grid[i][j]+vp[i-1][j][j];
                }
                else{
                    dp[i][j][g]=vp[i-1][N][j];
                }
                if (j > 0)
                    vp[i][j][g] = max(vp[i][j - 1][g], dp[i][j][g]+max(0,grid[i+1][j]-grid[i+1][g]));
                else
                    vp[i][j][g] = dp[i][j][g]+max(0,grid[i+1][j]-grid[i+1][g]);
            }
        }
    }
    long long  ans=0;
    for(int i=0;i<=N;i++){
        ans=max(ans,dp[N-1][i][0]);
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 878 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Runtime error 863 ms 2097152 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 809 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 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 432 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 35 ms 54088 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '207708106120'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 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 432 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 35 ms 54088 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '207708106120'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 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 432 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 35 ms 54088 KB 1st lines differ - on the 1st token, expected: '216624184325', found: '207708106120'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 809 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 878 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -