Submission #1082369

#TimeUsernameProblemLanguageResultExecution timeMemory
1082369jer033Catfish Farm (IOI22_fish)C++17
14 / 100
899 ms2097152 KiB
#include "fish.h" #include <bits/stdc++.h> #include <vector> using namespace std; using ll = long long; const ll NINF = -5'000'000'000'000'000; ll dp[450][15][15][15]; long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { vector<vector<ll>> fish(N, vector<ll> (N, 0)); //we can consider empty cells to have catfish worth 0 for (int i=0; i<M; i++) fish[X[i]][Y[i]] = W[i]; ll ans = 0; int limit = min(8, N); for (int r = 0; r < N; r++) { for (int i=0; i<=limit; i++) for (int j=0; j<=limit; j++) for (int k=0; k<=limit; k++) { ll history; ll current; history = 0; if (r!=0) { for (int guess = 0; guess<=limit; guess++) history = max(history, dp[r-1][guess][i][j]); } if ((r==0) and (i!=0)) current = NINF; else if ((r==(N-1)) and (k!=0)) current = NINF; else { current = 0; int reach = max(i, k); int start = j; for (int fishy = start; fishy<reach; fishy++) current += fish[r][fishy]; } dp[r][i][j][k] = history+current; ans = max(ans, history+current); } } 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...