Submission #838651

# Submission time Handle Problem Language Result Execution time Memory
838651 2023-08-27T14:09:05 Z Andrey Catfish Farm (IOI22_fish) C++17
0 / 100
297 ms 401052 KB
#include "fish.h"
#include<bits/stdc++.h>
#include <vector>
using namespace std;

long long haha[5000][5000];
long long dp[3001][3001][3];

long long max_weights(int n, int m, std::vector<int> x, std::vector<int> y, std::vector<int> w) {
    for(long long i = 0; i <= n; i++) {
        for(long long j = 0; j <= n; j++) {
            haha[i][j] = 0;
        }
    }
    for(long long i = 0; i < m; i++) {
        haha[x[i]][y[i]+1] = w[i];
    }
    for(long long i = 0; i < n; i++) {
        for(long long j = 1; j <= n; j++) {
            haha[i][j]+=haha[i][j-1];
        }
    }
    for(long long i = 0; i <= n; i++) {
        for(long long j = 0; j <= n; j++) {
            dp[i][j][0] = 0;
            dp[i][j][1] = 0;
            dp[i][j][2] = 0;
        }
    }
    for(int i = 0; i <= n; i++) {
        dp[0][i][0] = haha[1][i];
    }
    long long ans = 0;
    for(long long i = 1; i < n; i++) {
        for(long long j = 0; j <= n; j++) {
            for(long long k = 0; k <= n; k++) {
                long long c = haha[i+1][k];
                dp[i][k][0] = max(dp[i][k][0],dp[i-1][j][2]+c+max(0LL,haha[i-1][k]-haha[i-1][j]));
                if(k >= j) {
                    dp[i][k][0] = max(dp[i][k][0],dp[i-1][j][0]+c-haha[i][j]);
                }
                else if(k == 0) {
                    dp[i][j][2] = max(dp[i][j][2],dp[i-1][j][0]);
                    dp[i][j][2] = max(dp[i][j][2],dp[i-1][j][1]);
                }
                else {
                    dp[i][k][1] = max(dp[i][k][1],dp[i-1][j][0]+c-haha[i][k]);
                    dp[i][k][1] = max(dp[i][k][1],dp[i-1][j][1]+c-haha[i][k]);
                }
            }
        }
    }
    for(long long i = 0; i <= n; i++) {
        ans = max(ans,dp[n-1][i][0]);
        ans = max(ans,dp[n-1][i][1]);
        ans = max(ans,dp[n-1][i][2]);
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Runtime error 297 ms 401052 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 291 ms 397144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 291 ms 397144 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 297 ms 401052 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -