Language: C++

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define int long long

typedef pair<int, int> ii;

const int mod = 1e9 + 7;

const int N = 2e5 + 5;

const int inf = 1e15;

int dp[N], n, h[N], c, pter = 0;

vector<ii> vec;

int mul(int x, int y) {
    return (1ll * x * 1ll * y) % mod;
}

int del(int x, int y) {
    return ((1ll * x - 1ll * y) % mod + mod) % mod;
}

int findx(ii x, ii y) {
    return (y.se - x.se) / (x.fi - y.fi);
}

bool compare(ii x, ii y, ii z) {
    return(findx(x, y) > findx(x, z));
}

void add(int a, int b) {
    vec.pb({a, b});
    while(vec.size() >= 3 && compare(vec[vec.size() - 3], vec[vec.size() - 2], vec[vec.size() - 1])) {
        vec.pop_back();
        vec.pop_back();
        vec.pb({a, b});
    }
}

int query(int x) {
    pter = min(pter, 1ll * (vec.size()) - 1);
    while(pter + 1 < vec.size() && vec[pter].fi * x + vec[pter].se >= vec[pter + 1].fi * x + vec[pter + 1].se)
        pter++;
    return vec[pter].fi * x + vec[pter].se;
}

signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n >> c;
    for(int i = 1; i <= n; i++)
        cin >> h[i];
    dp[1] = 0;
    add(-2 * h[1], h[1] * h[1] + dp[1] + c);
    for(int i = 2; i <= n; i++) {
        dp[i] = query(h[i]) + h[i] * h[i];
        //cout << -2 * h[i] << " " << h[i] * h[i] + dp[i] + c << "\n";
        //cout << vec.size() << " " << i << "\n";
        add(-2 * h[i], h[i] * h[i] + dp[i] + c);
        //cout << dp[i] << " " << i << "\n";
    }
    cout << dp[n];
}



Compiler output:
a.cc: In function 'long long int query(long long int)':
a.cc:50:15: error: no matching function for call to 'min(long long int&, long long unsigned int)'
   50 |     pter = min(pter, 1ll * (vec.size()) - 1);
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:50:15: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   50 |     pter = min(pter, 1ll * (vec.size()) - 1);
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281: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:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:50:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   50 |     pter = min(pter, 1ll * (vec.size()) - 1);
      |            ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~