Problem p02658 (C++) — buggy submission, verdict: Runtime Error

//            ,O,i=0,Q=YUKU(f);static f*P;static FILE*t;static cons
//            char*o[]={//bad"
//          "\\n\\40\\"8oCan\\40not\\40open %s\\n\\0\\n\\40\\"8oCan\\40not\\40open
//          %s\\n#e(bad/bad",
//        "a6if(p==b*5&&O){p-=b;O--;}}return 0U;if(p==b*5&&O){p-=b;O--;}}return
//        0U;:b"",
//       "e&a6if(p==b*5&&O){p-=b;O--;}}return 0U;if(p==b*5&&O){p-=b;O--;}}return
//       0U;:b"",
//      "e&a6if(p==b*5&&O){p-=b;O--;}}return 0U;if(p==b*5&&O){p-=b;O--;}}return
//      0U;:"e#d",
//     ">bad/bad/"};static ll  S(){return(o[p][q]);}static/**/ll /**/Z=0
//     ;void/**/z(ll //
//    l){if(/**/Z-l){Z=l;q++;if(p<b*5&&!S()){p+=b;q=0;}}}ll  main(ll  I,
//    /**/char**l){//
//   d=YUKKUU(f*);if(1<(O=_)){b=((YUKKUU(o)/YUKKUU(char*))-1)/4;q=22; p=
//   0;while(p<b*5){
//  /*<*/if(Z-1){d=S()>96;i=S()-(d?96:32) ;q++;if(p<b*5&&!S()){p+=b;  q=
//  0;}Z=1;}/*[[*/ while(i){_=o[0][S()-97];I=_-10?b:1;   for( ;I--;)putchar(_
//  );if   (!      --i||d)z(~i );}
// if(p==b*5&&O){p-=b;O--;}}return 0U;   }if(! (P=( f*)calloc /*]*/  (Q
// ,I)))return 1;
// {;}for(_=p=1;p<I;p++){e(q=1);while    (q<   p&&  strcmp(  l[p     ]
// ,l[(q)]))++  q; t=stdin;if(q<p){(void)memcpy/* "      */    (&P  [p],&P   [q
// ]          ,Q);continue ;}
// if(strcmp(l[p],"-")){t=fopen(l         [     p]   ,"rb"   ) ;if(!t ){{;}  ;
// prll f(05+*o,l[p ]);return+1;                      {;} }}_=b= 1<<16   ;
//*&O=5;do{if(!(P[p].q=realloc   (P[p].q,(P[p].P     +=       b)+1))){return
//01;}O   &=72   / 6/*][*/;P[p].o+=d=fread(P[p]      .q       +P[     p ]. o,
// 1,b,t)   ;}//
// while(d==b)      ;P [p].q[       P[       p]                  .o       ]=
// 012;d    =0; e(fclose(t        )  );P         [p]      .p =P[      p]  .q;if
// (O) {for(;d<P[            p]          .o     ;d=                   q+     1)
// {q=     d;
//  while(q<P[                        p].o&&P[                    p].q[q]- 10 ){
//  q++;}b=q-d;                         _=P                         [p]. d     ;
//  if(b>_){/*]b */
//   P[p].d=b;}{; } #undef/*pqdz'.*/  e// ; #define/*s8qdb]*/e/**/0 //
//   //<<.<<.----.>.<<.>++.++<                                              .[>]
//   /*P[*/P[p].b++;continue;}}}t=                                       Yuki;
//  for (p=1;p<I;p++){/**/if(P[p].b>i ){i=P[p].b;}}
// if  (O){for(p=0;p<i;p++){q=0;/*[*/while(I               >++q){_=P[q].p-P[q
// ].q;
// b=   0;if(_<P[q ].o){while(012-*P[q].p)     {putchar(*(P[q].p++));b++;}P[q].
// p++; }   ;while (P[  q].d>b++)YUKKUU(040);}             putchar(10);}return
//0;}p   =1;
//   for(;   p<I   ;p++)YUKKUU(P[p] .q,P[              p].o,1,t);return 0 ;}//
//  #/*]     ]<.    [-]<[-]<[- ]<[    -]<               [-  ]<;*/Yuki  e    //b
// |(1        <<     ( __LINE__        /*               >>   `*//45))  |     01U
//
#include <bits/stdc++.h>
using namespace std;
long long int n, a, f, f2;
vector<long double> v;
long double b;
int main() {
  cin >> n;
  b = 1, f = 0, f2 = 0;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a == 0)
      f = 1;
    else if (a > 1000000000000000000)
      f2 = 1;
    v.push_back(a);
  }
  if (f)
    return cout << 0 << endl, 0;
  if (f2)
    return cout << -1 << endl, 0;
  for (int i = 0; i < n; i++) {
    b *= v[i];
    // cout<<b<<" ";
    if (b > 1000000000000000000)
      return cout << -1 << endl, 0;
  }
  cout << fixed << setprecision(0) << b;
  return 0;
}


Error: WA

Fixed submission:


#include <bits/stdc++.h>
using namespace std;

int main() {
  long long int n, i, b, x, y, s = 1, a[99999];
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    s *= a[i];
  }
  x = (pow(10, 18));
  if (s >= x) {
    cout << "-1" << endl;
    return 0;
  } else
    cout << s << endl;
  return 0;
}