Submission #1055183

#TimeUsernameProblemLanguageResultExecution timeMemory
1055183vjudge1Catfish Farm (IOI22_fish)C++17
0 / 100
666 ms2097152 KiB
#include "fish.h" #include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vll = vector<ll>; struct AIB { int n; vll V; AIB(int N) : n(N + 2), V(N + 2, 0) {} void update(int p, ll v) { ++p; while(p < n) { V[p] = max(V[p], v); p += p & -p; } } ll query(int p) { ++p; ll re = 0; if(p < 0) return 0; while(p) { re = max(re, V[p]); p -= p & -p; } return re; } }; struct maxSuf { int n; AIB A; maxSuf(int N) : n(N), A(N) {} void update(int p, ll v) { A.update(n - p - 1, v); } ll query(int p) { return A.query(n - p - 1); } }; ll max_weights(int n, int m, vi X, vi Y, vi W) { vector<vi> P(n); for(int i = 0; i < m; ++i) P[X[i]].push_back(i); int hm = 0; for(auto it : Y) hm = max(hm, it + 1); vector<vector<vll>> DP(n + 1, vector(hm + 1, vll(hm + 1, 0ll))); ll re = 0; for(int i = 0; i < n; ++i) { for(int h1 = 0; h1 < hm; ++h1) { for(int h2 = 0; h2 < hm; ++h2) { for(int h3 = 0; h3 < hm; ++h3) { int delta = 0; if(i) { for(auto it : P[i - 1]) { int y = Y[it]; if(y >= h2 && y >= h1 && y < h3) delta += W[it]; } } for(auto it : P[i]) { int y = Y[it]; if(y < h2 && y < h3) delta -= W[it]; } if(i + 1 < n) { for(auto it : P[i + 1]) { int y = Y[it]; if(y < h3) delta += W[it]; } } DP[i + 1][h2][h3] = max(DP[i + 1][h2][h3], DP[i][h1][h2] + delta); re = max(re, DP[i + 1][h2][h3]); } } } } 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...