Submission #797752

#TimeUsernameProblemLanguageResultExecution timeMemory
797752hugo_pmCatfish Farm (IOI22_fish)C++17
0 / 100
1149 ms2097152 KiB
#include <bits/stdc++.h> #include "fish.h" using namespace std; #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define rep(i, a, b) for(int i = (a); i < (b); i++) #define sz(v) ((int)((v).size())) template<typename T> void chmax(T &x, const T &v) { if (x < v) x = v; } template<typename T> void chmin(T &x, const T &v) { if (x > v) x = v; } using pii = pair<int, int>; string to_string(string s) { return s; } template <typename T> string to_string(T v) { bool first = true; string res = "["; for (const auto &x : v) { if (!first) res += ", "; first = false; res += to_string(x); } res += "]"; return res; } template <typename A, typename B> string to_string(pair<A, B> p) { return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; } void dbg_out() { cout << endl; } template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << to_string(H); dbg_out(T...); } #ifdef DEBUG #define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__) #else #define dbg(...) #endif using ll = long long; using v64 = vector<ll>; using a2v64 = array<v64, 2>; const ll INF = 3e18; const int INCR = 0, DECR = 1; ll max_weights(int szCarre, int nbFish, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { vector<v64> carre(szCarre, v64(szCarre)); rep(i, 0, nbFish) { carre[X[i]][Y[i]] = W[i]; } a2v64 minInf; minInf[0] = minInf[1] = v64(szCarre+1, -INF); a2v64 dpOld = minInf; dpOld[INCR][0] = 0; rep(col, 0, szCarre) { a2v64 dpNew = minInf; rep(oldTake, 0, szCarre+1) { ll somme = 0; rep(newTake, oldTake, szCarre+1) { if (col > 0 && newTake > oldTake) { somme += carre[col-1][newTake-1]; } chmax(dpNew[INCR][newTake], dpOld[INCR][oldTake] + somme); } } rep(oldTake, 0, szCarre+1) { ll somme = 0; for (int newTake = oldTake; newTake >= 0; --newTake) { if (newTake < oldTake) { somme += carre[col][newTake]; } chmax(dpNew[DECR][newTake], dpOld[DECR][oldTake] + somme); } } rep(take, 0, szCarre+1) { chmax(dpNew[DECR][take], dpNew[INCR][take]); } dpOld = dpNew; } return *max_element(all(dpOld[DECR])); }
#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...