Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
using namespace std;
 
const double EPS = 1e-9;
 
struct data{
  double lm, rm, m;//l-min, r-max
  int bit; 
  data(double l=0, double r=0, double m=0, int b=0):lm(l),rm(r),m(m),bit(b){}
};
 
bool equal(double a, double b){
  return fabs(a-b) < EPS;
}
 
int n;
double r;
vector<double> v;
 
void solve(){
  if(n == 1){
    cout << 0.0 << endl;
    return;
  }
 
  vector<data> res[7];
  double ans = -1.0;
  for(int i=0;i<n;i++) res[1].push_back(data(0,0,v[i],(1<<i)));
  for(int i=2;i<=n;i++){
    for(int j=1;j<i;j++){
      int x1 = j, x2 = i - j;
      for(int k=0;k<res[x1].size();k++){
        for(int l=0;l<res[x2].size();l++){
          if((res[x1][k].bit & res[x2][l].bit) != 0) continue;
          data pos;
          double a = res[x2][l].m / (res[x1][k].m + res[x2][l].m);
          double b = 1.0 - a;
          pos.lm = min(-a + res[x1][k].lm, b + res[x2][l].lm);
          pos.rm = max(b + res[x2][l].rm, -a + res[x1][k].rm);
          pos.m = res[x1][k].m + res[x2][l].m;
          pos.bit = res[x1][k].bit | res[x2][l].bit;
          if(pos.rm - pos.lm > r || equal(pos.rm-pos.lm,r)) continue;
          else if(i == n) ans = max(ans, pos.rm - pos.lm);
          else res[i].push_back(pos);
        }
      }
    }
  }
  if(ans < 0) cout << -1 << endl;
  else printf("%.9f\n",ans);
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:30:14: error: template argument 1 is invalid
   30 |   vector<data> res[7];
      |              ^
a.cc:30:14: error: template argument 2 is invalid
a.cc:32:31: error: request for member 'push_back' in 'res[1]', which is of non-class type 'int'
   32 |   for(int i=0;i<n;i++) res[1].push_back(data(0,0,v[i],(1<<i)));
      |                               ^~~~~~~~~
a.cc:32:41: error: reference to 'data' is ambiguous
   32 |   for(int i=0;i<n;i++) res[1].push_back(data(0,0,v[i],(1<<i)));
      |                                         ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:10:8: note:                 'struct data'
   10 | struct data{
      |        ^~~~
a.cc:36:29: error: request for member 'size' in 'res[x1]', which is of non-class type 'int'
   36 |       for(int k=0;k<res[x1].size();k++){
      |                             ^~~~
a.cc:37:31: error: request for member 'size' in 'res[x2]', which is of non-class type 'int'
   37 |         for(int l=0;l<res[x2].size();l++){
      |                               ^~~~
a.cc:38:22: error: invalid types 'int[int]' for array subscript
   38 |           if((res[x1][k].bit & res[x2][l].bit) != 0) continue;
      |                      ^
a.cc:38:39: error: invalid types 'int[int]' for array subscript
   38 |           if((res[x1][k].bit & res[x2][l].bit) != 0) continue;
      |                                       ^
a.cc:39:11: error: reference to 'data' is ambiguous
   39 |           data pos;
      |           ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:10:8: note:                 'struct data'
   10 | struct data{
      |        ^~~~
a.cc:40:29: error: invalid types 'int[int]' for array subscript
   40 |           double a = res[x2][l].m / (res[x1][k].m + res[x2][l].m);
      |                             ^
a.cc:40:45: error: invalid types 'int[int]' for array subscript
   40 |           double a = res[x2][l].m / (res[x1][k].m + res[x2][l].m);
      |                                             ^
a.cc:40:60: error: invalid types 'int[int]' for array subscript
   40 |           double a = res[x2][l].m / (res[x1][k].m + res[x2][l].m);
      |                                                            ^
a.cc:42:11: error: 'pos' was not declared in this scope; did you mean 'pow'?
   42 |           pos.lm = min(-a + res[x1][k].lm, b + res[x2][l].lm);
      |           ^~~
      |           pow
a.cc:42:36: error: invalid types 'int[int]' for array subscript
   42 |           pos.lm = min(-a + res[x1][k].lm, b + res[x2][l].lm);
      |                                    ^
a.cc:42:55: error: invalid types 'int[int]' for array subscript
   42 |           pos.lm = min(-a + res[x1][k].lm, b + res[x2][l].lm);
      |                                                       ^
a.cc:43:35: error: invalid types 'int[int]' for array subscript
   43 |           pos.rm = max(b + res[x2][l].rm, -a + res[x1][k].rm);
      |                                   ^
a.cc:43:55: error: invalid types 'int[int]' for array subscript
   43 |           pos.rm = max(b + res[x2][l].rm, -a + res[x1][k].rm);
      |                                                       ^
a.cc:44:26: error: invalid types 'int[int]' for array subscript
   44 |           pos.m = res[x1][k].m + res[x2][l].m;
      |                          ^
a.cc:44:41: error: invalid types 'int[int]' for array subscript
   44 |           pos.m = res[x1][k].m + res[x2][l].m;
      |                                         ^
a.cc:45:28: error: invalid types 'int[int]' for array subscript
   45 |           pos.bit = res[x1][k].bit | res[x2][l].bit;
      |                            ^
a.cc:45:45: error: invalid types 'int[int]' for array subscript
   45 |           pos.bit = res[x1][k].bit | res[x2][l].bit;
      |                                             ^
a.cc:48:23: error: request for member 'push_back' in 'res[i]', which is of non-class type 'int'
   48 |           else res[i].push_back(pos);
      |                       ^~~~~~~~~