Language: C++

#include<bits/stdc++.h>
#define task "MAXFRAME"

#define nguyen_dz the_best
#define ll long long
#define ld long double
#define pb push_back
#define endl "\n"
#define ff first
#define ss second
#define pll pair<ll,ll>
#define YES cout <<"YES"<<endl;
#define NO cout <<"NO"<<endl;
#define Yes cout <<"Yes"<<endl;
#define No cout<<"No" <<endl;


using namespace std;
const ll  maxn= 4e6+100;

ll a[maxn];
ll dp[maxn];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("test.txt","r",stdin);
    if (fopen(task".INP","r"))
    {
        freopen(task".INP", "r", stdin);
        freopen(task".OUT", "w", stdout);
    }
   ll n;
   cin>> n;
   for (int i=0;i<=n;i++)
   {
       cin>>a[i];
   }
   ll res=1;

   for (int i=0;i<=n;i++)
   {
       //  ans=ans+res;
     //    cout <<res<<endl;
     dp[i]=res;
       if (res<a[i])
       {
           cout <<-1;
           return 0;
       }
       else
       {
           res-=a[i];
       }
     //  cout <<res<<endl;
  // if(i!=n) ans=ans+res+a[i];
       res*=2;
      // ll p =min(i+1,60);
       res=min(res,1e17);

   //   if (i!=n)

   }
   //ans/=2;
   ll nw=0;
   ll ans=0;
  for (int i=n;i>=0;i--)
  {

      nw+=a[i];
      ans=ans+min(nw,dp[i]);
  }
  cout <<ans;


}



Compiler output:
a.cc: In function 'int main()':
a.cc:60:15: error: no matching function for call to 'min(long long int&, double)'
   60 |        res=min(res,1e17);
      |            ~~~^~~~~~~~~~
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:60:15: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'double')
   60 |        res=min(res,1e17);
      |            ~~~^~~~~~~~~~
/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:60:15: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   60 |        res=min(res,1e17);
      |            ~~~^~~~~~~~~~