#include <bits/stdc++.h>
#define pb push_back
#define int int64_t
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
#define DEBUGGING
#ifdef DEBUGGING
#include "../debug.h"
#else
#define debug(x...) void(42)
#endif
int n;
int m;
constexpr static int MXN = 1e5 + 5;
constexpr static int INC = 0;
constexpr static int DEC = 1;
constexpr static int ZER = 2;
vector<array<int, 3>> dp[MXN]; // Y position, height (in fish units), state (increasing, decreasing, zeroed (returns previous height)
vector<int> lpf[MXN];
vector<int> rpf[MXN];
vector<array<int, 2>> f[MXN]; // X pos, Y pos, height/weight
int max_weights(int32_t N, int32_t M, vector<int32_t> x, vector<int32_t> y, vector<int32_t> w)
{
n = N;
m = M;
for (int i = 0; i < m; i++)
f[x[i]].pb({y[i], w[i]});
for (int i = 0; i < n; i++)
sort(f[i].begin(), f[i].end());
dp[0]= vector<array<int,3>>(f[0].size()+1, array<int, 3>({0, 0, 0}));
for (int i = 0; i <= f[0].size(); i++)
{
dp[0][i][INC] = 0;
dp[0][i][DEC] = 0;
}
for (int i = 1; i < n; i++)
{
dp[i]= vector<array<int,3>>(f[i].size()+1, array<int, 3>({0, 0, 0}));
// Calculate prefixes
// Calculate INC -> INC
int k = 0; // Previous level
for (int j = 0; j < f[i].size(); j++) // Current level
{
if (j > 0)
dp[i][j][INC] = max(dp[i][j][INC], dp[i][j-1][INC]);
while (k < f[i-1].size() && f[i][j][0] > f[i-1][k][0])
{
dp[i][j][INC] = max(dp[i][j][INC], dp[i-1][k][INC]) + f[i-1][k][1];
k++;
}
}
dp[i][f[i].size()][INC] = max(dp[i][f[i].size()-1][INC], dp[i-1][k][INC]);
// Calculating DEC -> DEC
k = f[i-1].size(); // Previous level
for (int j = f[i].size(); j >= 0; j--)
{
if (j < f[i].size())
dp[i][j][DEC] = max(dp[i][j][DEC], dp[i][j+1][DEC]);
while (k >= 0 && (k == f[i-1].size() || (j != f[i].size() && f[i-1][k][0] > f[i][j][0])))
{
dp[i][j][DEC] = max(dp[i][j][DEC], dp[i-1][k][DEC]);
k--;
}
if (j < f[i].size())
dp[i][j][DEC] += f[i][j][1];
}
// Calculating INC -> DEC (it's only reasonable at the peak
dp[i][f[i].size()][DEC] = max(dp[i][f[i].size()][DEC], dp[i][f[i].size()][INC]);
// Calculating DEC -> ZER
k = 0;
for (int j = 0; j <= f[i].size(); j++)
{
while (k < f[i-1].size() && (j == f[i].size() || f[i-1][k][0] < f[i][j][0]))
{
dp[i][j][ZER] = max(dp[i][j][ZER], dp[i-1][k][DEC]);
k++;
}
}
dp[i][f[i].size()][ZER] = max(dp[i][f[i].size()][ZER], dp[i-1][f[i-1].size()][DEC]);
// Calculating ZER -> INC
vector<int> best_upper(f[i].size()+1);
k = f[i-1].size();
int change = 0;
for (int j = 0; j < f[i-1].size(); j++)
change += f[i-1][j][1];
for (int j = f[i].size(); j>= 0; j--)
{
if (j < f[i].size())
best_upper[j] = max(best_upper[j], best_upper[j+1]);
while (k > 0 && (k == f[i-1].size() || f[i-1][k][0] > f[i-1][j][0]))
{
best_upper[j] = max(best_upper[j], dp[i-1][k][ZER] + change);
k--;
if (k >= 0)
change -= f[i-1][k][1];
}
}
k = 0;
int sum = 0;
int prev_val = 0;
for (int j = 0; j <= f[i].size(); j++)
{
dp[i][j][INC] = max(dp[i][j][INC], best_upper[j]);
while (k < f[i-1].size() && (j == f[i].size() || f[i-1][k][0] < f[i][j][0]))
{
prev_val = max(prev_val, dp[i-1][k][ZER]);
sum += f[i-1][k][1];
dp[i][j][INC] = max({dp[i][j][INC], prev_val + sum});
k++;
}
}
}
int best = 0;
for (int i = 0; i < f[n-1].size(); i++)
best = max({best, dp[n-1][i][DEC], dp[n-1][i][INC], dp[n-1][i][ZER]});
return best;
}
Compilation message
fish.cpp:10:10: fatal error: ../debug.h: No such file or directory
10 | #include "../debug.h"
| ^~~~~~~~~~~~
compilation terminated.