Language: C++

#include<iostream> #include<algorithm> #include<cmath> #include<vector> #include<queue> #include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
//cpp_int 多倍長
using namespace std; #define int long long #define REP(i,s,e) for((i)=(s);(i)<(e);(i)++) #define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
int A[100001];
cpp_int mxa[100001];
int N;
int sol(){
   //test();
   cin>>N;
   int mn=1;
   cpp_int mx=1;
   for(int i=0;i<N+1;i++){
       cin>>A[i];
       //cout<<",,,,"<<mx<<endl;
       mx-=A[i];
       mxa[i]=mx;
       if(mx<=0&&i!=N||mx<0&&i==N){
           //cout<<"-1"<<endl;
           return -1;
       }
       mx*=2;
   }

   int bef=A[N];
   int ans=A[N];
   for(int i=N-1;i>=0;i--){
       //cout<<ans<<","<<bef<<","<<mxa[i]<<endl;
       if(mxa[i]>bef) mxa[i]=bef;
       ans+=min(bef,(long long)mxa[i])+A[i];
       bef=min(bef,(long long)mxa[i])+A[i];
   }
   return ans;
}
signed main(){
 cout<<sol()<<endl;
}

Compiler output:
a.cc:1:20: warning: extra tokens at end of #include directive
    1 | #include<iostream> #include<algorithm> #include<cmath> #include<vector> #include<queue> #include<boost/multiprecision/cpp_int.hpp>
      |                    ^
a.cc:5:22: error: stray '#' in program
    5 | using namespace std; #define int long long #define REP(i,s,e) for((i)=(s);(i)<(e);(i)++) #define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
      |                      ^
a.cc:5:44: error: stray '#' in program
    5 | using namespace std; #define int long long #define REP(i,s,e) for((i)=(s);(i)<(e);(i)++) #define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
      |                                            ^
a.cc:5:90: error: stray '#' in program
    5 | using namespace std; #define int long long #define REP(i,s,e) for((i)=(s);(i)<(e);(i)++) #define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
      |                                                                                          ^
a.cc:3:17: error: 'boost' has not been declared
    3 | using namespace boost::multiprecision;
      |                 ^~~~~
a.cc:3:24: error: 'multiprecision' is not a namespace-name
    3 | using namespace boost::multiprecision;
      |                        ^~~~~~~~~~~~~~
a.cc:5:23: error: 'define' does not name a type
    5 | using namespace std; #define int long long #define REP(i,s,e) for((i)=(s);(i)<(e);(i)++) #define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
      |                       ^~~~~~
a.cc:5:78: error: expected constructor, destructor, or type conversion before '<' token
    5 | using namespace std; #define int long long #define REP(i,s,e) for((i)=(s);(i)<(e);(i)++) #define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
      |                                                                              ^
a.cc:5:86: error: expected constructor, destructor, or type conversion before '++' token
    5 | using namespace std; #define int long long #define REP(i,s,e) for((i)=(s);(i)<(e);(i)++) #define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
      |                                                                                      ^~
a.cc:5:129: error: expected constructor, destructor, or type conversion before '>=' token
    5 | using namespace std; #define int long long #define REP(i,s,e) for((i)=(s);(i)<(e);(i)++) #define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
      |                                                                                                                                 ^~
a.cc:5:138: error: expected constructor, destructor, or type conversion before '--' token
    5 | using namespace std; #define int long long #define REP(i,s,e) for((i)=(s);(i)<(e);(i)++) #define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
      |                                                                                                                                          ^~
a.cc:7:1: error: 'cpp_int' does not name a type; did you mean 'u_int'?
    7 | cpp_int mxa[100001];
      | ^~~~~~~
      | u_int
a.cc: In function 'int sol()':
a.cc:13:4: error: 'cpp_int' was not declared in this scope; did you mean 'u_int'?
   13 |    cpp_int mx=1;
      |    ^~~~~~~
      |    u_int
a.cc:15:13: error: 'A' was not declared in this scope
   15 |        cin>>A[i];
      |             ^
a.cc:17:8: error: 'mx' was not declared in this scope; did you mean 'mn'?
   17 |        mx-=A[i];
      |        ^~
      |        mn
a.cc:18:8: error: 'mxa' was not declared in this scope
   18 |        mxa[i]=mx;
      |        ^~~
a.cc:26:12: error: 'A' was not declared in this scope
   26 |    int bef=A[N];
      |            ^
a.cc:30:11: error: 'mxa' was not declared in this scope
   30 |        if(mxa[i]>bef) mxa[i]=bef;
      |           ^~~
a.cc:31:32: error: 'mxa' was not declared in this scope
   31 |        ans+=min(bef,(long long)mxa[i])+A[i];
      |                                ^~~