Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > piii;
#define pb push_back
#define debug(x) cout << x << endl
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define PI acos(-1)
#define all(c) c.begin(), c.end()
#define SET(x, y) memset((x), y, sizeof(x))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const LL INF64 = 1e18;

const int N = 1e5 + 5;

LL BIT[2 * N];
LL height[2 * N];
LL beauty[2 * N];

LL upd(LL x, LL val) {
	for(; x < 2 * N; x += x & (-x))
		BIT[x] = max(val, BIT[x]);
}

LL getMax(LL x) {
	LL ret = 0LL;
	for(; x > 0; x -= x & (-x))
		ret = max(BIT[x], ret);
	return ret;
}

int main() {
	SET(BIT, 0);
	int n;
	scanf("%d", &n);
	LL ans = 0LL;
	for (int i = 0; i < n; i++) 
		scanf("%lld", height + i);
	for (int i = 0; i < n; i++)
		scanf("%lld", beauty + i);
	for (int i = 0; i < n; i++) {
		LL mx = getMax(height[i] - 1);
		mx += beauty[i];
		upd(height[i], mx);
		ans = max(ans, max);
	}
	printf("%lld\n", ans);
	return 0;
}
		

Compiler output:
a.cc: In function 'LL upd(LL, LL)':
a.cc:25:1: warning: no return statement in function returning non-void [-Wreturn-type]
   25 | }
      | ^
a.cc: In function 'int main()':
a.cc:47:26: error: no matching function for call to 'max(LL&, <unresolved overloaded function type>)'
   47 |                 ans = max(ans, max);
      |                       ~~~^~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'constexpr const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = long long int]'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:36: note:   no known conversion for argument 2 from '<unresolved overloaded function type>' to 'const long long int&'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |                         ~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:47:26: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   47 |                 ans = max(ans, max);
      |                       ~~~^~~~~~~~~~