Submission #1076239

#TimeUsernameProblemLanguageResultExecution timeMemory
1076239vjudge1Catfish Farm (IOI22_fish)C++17
0 / 100
851 ms2097152 KiB
#include "fish.h" #include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using ii = pair<int, int>; using vll = vector<ll>; ll max_weights(int n, int m, vi X, vi Y, vi W) { int maxy = 0; for(int i = 0; i < m; ++i) { maxy = max(maxy, Y[i]); } vector<vector<ll> > C(n, vll(maxy + 1, 0)); for(int i = 0; i < m; ++i) { C[X[i]][Y[i]] = W[i]; } const ll INF = 1e9; vector<vector<vll> > DP(n + 1, vector(maxy + 1, vll(maxy + 1, -INF))); DP[0][0][0] = 0; ll re = 0; for(int i = 0; i < n; ++i) { for(int h2 = 0; h2 <= maxy; ++h2) { for(int h1 = 0; h1 <= maxy; ++h1) { ll cost0 = 0; for(int j = 0; j <= maxy; ++j) { if(j <= h1) cost0 += C[i][j]; } for(int h = 0; h <= maxy; ++h) { ll cnou = 0; for(int j = 0; j <= maxy; ++j) { if(j > h && j <= h1) cnou += C[i][j]; if(j <= h && i + 1 < n) cnou += C[i + 1][j]; if(j <= h && j > h1 && j > h2 && i) cnou += C[i - 1][j]; } DP[i + 1][h1][h] = max(DP[i + 1][h1][h], DP[i][h2][h1] + cnou - cost0); re = max(re, DP[i + 1][h1][h]); } } } } return re; }
#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...