Submission #628644

# Submission time Handle Problem Language Result Execution time Memory
628644 2022-08-13T14:46:27 Z Ronin13 Catfish Farm (IOI22_fish) C++17
0 / 100
1000 ms 77980 KB
#include "fish.h"
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define f first
#define s second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define epb emplace_back
#include <vector>
using namespace std;

const int NMAX = 3005;
ll dp[NMAX][NMAX];//klebadi
ll DP[NMAX][NMAX];//zrdadi
ll val[NMAX][NMAX];
const ll linf = 1e18;
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;
    for(int i = 0; i < m; i++){
        val[X[i] + 1][Y[i] + 1] = W[i];
    }
    /*for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++) cout << val[i][j] << ' ';
        cout << "\n";
    }*/


    DP[0][0] = 0;
    for(int i = 1; i <= n + 1; i++){
        if(i != 1){
            for(int j = n; j >= 1; j--){
                if(j == n){
                    dp[i][j] = min(DP[i - 2][j], dp[i - 2][1]) + val[i][j];
                }
                else dp[i][j] = max(dp[i - 1][j + 1], dp[i][j + 1]) + val[i][j];
            // dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            }
        }
        for(int j = 1; j <= n; j++){
            if(j == 1)DP[i][j] = dp[i - 1][j] + val[i][j];
            else DP[i][j] = max(DP[i - 1][j - 1], DP[i][j - 1]) + val[i][j];
          //  DP[i][j] = max(DP[i - 1][j], DP[i][j]);
        }
    }

    for(int i = 1; i <= n + 1; i++) dp[n + 1][1] = max(dp[i][1], dp[n + 1][1]);
    return dp[n + 1][1];
    return 0;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 77980 KB Time limit exceeded
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 Execution timed out 1095 ms 69576 KB Time limit exceeded
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: '3', found: '1'
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: '3', found: '1'
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: '3', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 69576 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 77980 KB Time limit exceeded
2 Halted 0 ms 0 KB -