Language: C++

#include<bits/stdc++.h>
#define inf 200000000000000000
#define eb emplace_back
#define pb push_back
#define fi first
#define se second
#define fastio ios::sync_with_stdio(false);cin.tie(NULL)
#define rng_23 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<pair<ll,ll>> vii;
typedef set<ll> si;
typedef multiset<ll> msi;
typedef map<ll,ll> mii;
ll ara[100001],cnt[100001],hcnt[100001],ans[100001];
int main()
{
    ll i,j,k;
    ll n;
    scanf("%lld",&n);
    for(i=0;i<=n;i++){
        scanf("%lld",&ara[i]);
        cnt[i]=ara[i];
    }
    for(i=n;i>=0;i--){
        if(log2((double)cnt[i])>(double)i){
            printf("-1");
            return 0;
        }
        cnt[i-1]+=(cnt[i]+1)/2;
    }
    for(i=1,hcnt[0]=1;i<=n;i++){
        hcnt[i]=min(2*(hcnt[i-1]-ara[i-1]),inf);
        //cout<<hcnt[i]<<endl;
    }
    ll res=ara[n];
    for(i=n-1,ans[n]=ara[n];i>=0;i--){
        ans[i]=min(ans[i+1]+ara[i],hcnt[i]);
        res+=ans[i];
    }
    printf("%lld",res);
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:20: error: no matching function for call to 'min(ll, long int)'
   35 |         hcnt[i]=min(2*(hcnt[i-1]-ara[i-1]),inf);
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:35:20: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long int')
   35 |         hcnt[i]=min(2*(hcnt[i-1]-ara[i-1]),inf);
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:35:20: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   35 |         hcnt[i]=min(2*(hcnt[i-1]-ara[i-1]),inf);
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~