Problem p03168 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
// For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test                                                                   \
  int t;                                                                       \
  cin >> t;                                                                    \
  while (t--)
#define init(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, a, b) for (int i = a; i < b; i++)
#define loopr(i, a, b) for (int i = a; i >= b; i--)
#define loops(i, a, b, step) for (int i = a; i < b; i += step)
#define looprs(i, a, b, step) for (int i = a; i >= b; i -= step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie();                                                                   \
  cout.tie();
#define FILE_READ_IN freopen("input.txt", "r", stdin);
#define FILE_READ_OUT freopen("output.txt", "w", stdout);
#define all(a) a.begin(), a.end()
#define ld long double
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);
int main() {
  ll n;
  cin >> n;
  ld A[n];
  loop(i, 0, n) { cin >> A[i]; }
  ld prob[100][100];
  init(prob, 0);
  prob[0][0] = 1.0;
  loop(i, 1, n + 1) { prob[i][0] = prob[i - 1][0] * (1 - A[i - 1]); }
  loop(i, 1, n + 1) {
    loop(j, 1, n + 1) {
      if (j > i) {
        break;
      }
      prob[i][j] =
          A[i - 1] * prob[i - 1][j - 1] + (1 - A[i - 1]) * prob[i - 1][j];
    }
  }
  // loop(i,0,n+1){
  //    loop(j,0,n+1){
  //       cout<<prob[i][j]<<" ";
  //    }
  //    cout<<"\n";
  // }
  ld ans = 0;
  ll mid = n / 2;
  loop(j, mid + 1, n + 1) { ans += prob[n][j]; }
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
// For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test                                                                   \
  int t;                                                                       \
  cin >> t;                                                                    \
  while (t--)
#define init(arr, val) memset(arr, val, sizeof(arr))
#define loop(i, a, b) for (int i = a; i < b; i++)
#define loopr(i, a, b) for (int i = a; i >= b; i--)
#define loops(i, a, b, step) for (int i = a; i < b; i += step)
#define looprs(i, a, b, step) for (int i = a; i >= b; i -= step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie();                                                                   \
  cout.tie();
#define FILE_READ_IN freopen("input.txt", "r", stdin);
#define FILE_READ_OUT freopen("output.txt", "w", stdout);
#define all(a) a.begin(), a.end()
#define ld long double
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);
int main() {
  ll n;
  cin >> n;
  ld A[n];
  loop(i, 0, n) { cin >> A[i]; }
  ld prob[3000][3000];
  init(prob, 0);
  prob[0][0] = 1.0;
  loop(i, 1, n + 1) { prob[i][0] = prob[i - 1][0] * (1 - A[i - 1]); }
  loop(i, 1, n + 1) {
    loop(j, 1, n + 1) {
      if (j > i) {
        break;
      }
      prob[i][j] =
          A[i - 1] * prob[i - 1][j - 1] + (1 - A[i - 1]) * prob[i - 1][j];
    }
  }
  // loop(i,0,n+1){
  //    loop(j,0,n+1){
  //       cout<<prob[i][j]<<" ";
  //    }
  //    cout<<"\n";
  // }
  ld ans = 0;
  ll mid = n / 2;
  loop(j, mid + 1, n + 1) { ans += prob[n][j]; }
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}