Submission #838598

#TimeUsernameProblemLanguageResultExecution timeMemory
838598AndreyCatfish Farm (IOI22_fish)C++17
0 / 100
1054 ms404944 KiB
#include "fish.h"
#include<bits/stdc++.h>
#include <vector>
using namespace std;

long long haha[5000][5000];
long long dp[300][300][300];

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[0][i][j] = 0;
        }
    }
    long long ans = 0;
    for(long long i = 1; i < n; i++) {
        for(long long j = 0; j <= n; j++) {
            if(i == 1 && j > 0) {
                continue;
            }
            for(long long k = 0; k <= n; k++) {
                for(long long y = 0; y <= n; y++) {
                    long long c = dp[i-1][j][k];
                    if(max(j,y) > k) {
                        c+=haha[i-1][max(j,y)]-haha[i-1][k];
                    }
                    dp[i][k][y] = max(c,dp[i][k][y]);
                }
            }
        }
    }
    for(long long i = 0; i <= n; i++) {
        for(long long j = 0; j <= n; j++) {
            long long c = dp[n-1][i][j];
            if(i > j) {
                c+=haha[n-1][i]-haha[n-1][j];
            }
            ans = max(ans,c);
        }
    }
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...