Language: C++

#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
using namespace std;

using ll = long long;

template <typename T, const T id>
class CHT {
	struct line {
		T a, b;
		line(T a_ = 0, T b_ = 0) : a(a_), b(b_) {}
		T get(T x) { return a * x + b; }
	};
	struct node {
		line l;
		node *lch, *rch;
		node(line l_) : l(l_), lch(nullptr), rch(nullptr) {}
		~node() {
			if (lch) delete lch;
			if (rch) delete rch;
		}
	};

private:
	const int n;
	const vector<T> pos;
	node *root;

public:
	CHT(const vector<T>& pos_) : n(pos_.size()), pos(pos_), root(nullptr) {}
	~CHT() {
		if (root) delete root;
	}
	void insert(T a, T b) {
		line l(a, b);
		root = modify(root, 0, n, l);
	}
	T get(T x) const {
		int t = lower_bound(pos.begin(), pos.end(), x) - pos.begin();
		//assert(t < n && pos[t] == x);
		return sub(root, 0, n, t);
	}

private:
	node* modify(node *p, int lb, int ub, line& l) {
		if (!p) return new node(l);
		if (p->l.get(pos[lb]) >= l.get(pos[lb]) && p->l.get(pos[ub - 1]) >= l.get(pos[ub - 1])) return p;
		if (p->l.get(pos[lb]) <= l.get(pos[lb]) && p->l.get(pos[ub - 1]) <= l.get(pos[ub - 1])) {
			p->l = l;
			return p;
		}
		int c = (lb + ub) / 2;
		if (p->l.get(pos[c]) < l.get(pos[c])) swap(p->l, l);
		if (p->l.get(pos[lb]) <= l.get(pos[lb]))
			p->lch = modify(p->lch, lb, c, l);
		else
			p->rch = modify(p->rch, c, ub, l);
		return p;
	}
	T sub(node *p, int lb, int ub, int t) const {
		if (!p) return id;
		if (ub - lb == 1) return p->l.get(pos[t]);
		int c = (lb + ub) / 2;
		if (t < c) return max(p->l.get(pos[t]), sub(p->lch, lb, c, t));
		return max(p->l.get(pos[t]), sub(p->rch, c, ub, t));
	}
};


int main() {
	int Q;
	int N;
	ll C;
	cin >> N >> C;
	vector<ll> H(N);
	for (int i = 0; i < N; i++)
	{
		cin >> H[i];
	}

	vector<ll> dp(N);
	dp[0] = 0;
	ll Score0 = H[0] * H[0] + C;
	ll Score1 = (H[0] - 1) * (H[0] - 1) + C - 1;


	CHT<ll, LLONG_MIN> ct(H);
	ct.insert(-(Score1 - Score0), -Score0);

	for (int i = 1; i < N; i++)
	{
		dp[i] = -ct.get(H[i]) + H[i] * H[i];
		Score0 = H[i] * H[i] + C + dp[i];
		Score1 = (H[i] - 1) * (H[i] - 1) + C - 1 + dp[i];

		ct.insert(-(Score1 - Score0), -Score0);
	}

	cout << dp[N - 1] << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:93:17: error: 'LLONG_MIN' was not declared in this scope
   93 |         CHT<ll, LLONG_MIN> ct(H);
      |                 ^~~~~~~~~
a.cc:9:1: note: 'LLONG_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    8 | #include<map>
  +++ |+#include <climits>
    9 | using namespace std;
a.cc:93:26: error: template argument 2 is invalid
   93 |         CHT<ll, LLONG_MIN> ct(H);
      |                          ^
a.cc:93:31: error: cannot convert 'std::vector<long long int>' to 'int' in initialization
   93 |         CHT<ll, LLONG_MIN> ct(H);
      |                               ^
      |                               |
      |                               std::vector<long long int>
a.cc:94:12: error: request for member 'insert' in 'ct', which is of non-class type 'int'
   94 |         ct.insert(-(Score1 - Score0), -Score0);
      |            ^~~~~~
a.cc:98:29: error: request for member 'get' in 'ct', which is of non-class type 'int'
   98 |                 dp[i] = -ct.get(H[i]) + H[i] * H[i];
      |                             ^~~
a.cc:102:20: error: request for member 'insert' in 'ct', which is of non-class type 'int'
  102 |                 ct.insert(-(Score1 - Score0), -Score0);
      |                    ^~~~~~