# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
629066 | 2022-08-14T06:53:35 Z | Justin1 | Catfish Farm (IOI22_fish) | C++17 | 0 ms | 0 KB |
#include "fish.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; ll ps1[100005], ps2[100005]; long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) { for (int i = 0; i < M; i++) { if (X[i] == 0) ps1[Y[i]] += W[i]; else ps2[Y[i]] += W[i]; } for (int i = 1; i < N; i++) ps1[i] += ps1[i-1]; for (int i = N-1; i >= 0; i--) ps2[i] += ps2[i+1]; ll ans = ps[0]; for (int i = 0; i < N; i++) ans = max(ans,ps1[i] + ps2[i+1]); return ans; }