#include <bts/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
int n; //global var for storing N
vector<pair<int, int> > fishes[100005]; //Stores the fishes in each row
struct SegmentTree{
ll tree[1 << 18];
void init(){
memset(tree, 0xcf, sizeof(tree))
}
void upd(int idx, int s, int e, int l, int r, ll val){
if(e < l || r < s) return;
if(l <= s && e <= r){
tree[idx] = max(tree[idx], val);
return;
}
int mid = (s + e) / 2;
upd(2 * idx, s, mid, l, r, val);
upd(2 * idx + 1, mid + 1, e, l, r, val);
}
ll qry(int idx, int s, int e, int x){
if(s == e) return tree[idx];
int mid = (s + e) / 2;
if(x <= m) return qry(2 * idx, s, mid, x);
return qry(2 * idx + 1, mid + 1, e, x);
}
}st_up, st_down;
ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W){
n = N;
for(int i = 0; i < M; i++) fishes[X[i] + 1].push_back({Y[i] + 1, W[i]});
ll till_now = 0;
st_down.init();
for(int i = 1; i <= n; i++){
sort(fishes[i].begin(), fishes[i].end());
for(auto [j, w] : fishes[i]) st_up.upd(1, 0, n + 1, j + 1, n + 1, st_up.qry(1, 0, n + 1, j) + w);
reverse(fishes[i].begin(), fishes[i].end());
for(auto [j, w] : fishes[i]) st_down.upd(1, 0, n + 1, 0, j - 1, st_down.qry(1, 0, n + 1, j) + w);
ll u_res = st_up.qry(1, 0, n + 1, n + 1), d_res = st_down.qry(1, 0, n + 1, 0);
st_up.upd(1, 0, n + 1, 0, n + 1, d_res);
st_down.upd(1, 0, n + 1, 0, n + 1, till_now);
till_now = max(u_res, d_res);
}
return st_down.qry(1, 0, n + 1, 0);
}
Compilation message
fish.cpp:1:10: fatal error: bts/stdc++.h: No such file or directory
1 | #include <bts/stdc++.h>
| ^~~~~~~~~~~~~~
compilation terminated.