Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

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){}
};

int n;
double r;
vector<double> v;

void solve(){
  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) continue;
          else if(i == n) ans = max(ans, pos.rm - pos.lm);
          else res[i].push_back(pos);
        }
      }
    }
  }
  printf("%.9f\n",ans);
}

int main(){
  int T;
  cin >> T;
  while(T--){
    cin >> r >> n;
    v.clear();
    for(int i=0;i<n;i++){
      int x;
      cin >> x;
      v.push_back(x);
    }
    solve();
  }
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:17:14: error: template argument 1 is invalid
   17 |   vector<data> res[7];
      |              ^
a.cc:17:14: error: template argument 2 is invalid
a.cc:19:31: error: request for member 'push_back' in 'res[1]', which is of non-class type 'int'
   19 |   for(int i=0;i<n;i++) res[1].push_back(data(0,0,v[i],(1<<i)));
      |                               ^~~~~~~~~
a.cc:19:41: error: reference to 'data' is ambiguous
   19 |   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:6:8: note:                 'struct data'
    6 | struct data{
      |        ^~~~
a.cc:23:29: error: request for member 'size' in 'res[x1]', which is of non-class type 'int'
   23 |       for(int k=0;k<res[x1].size();k++){
      |                             ^~~~
a.cc:24:31: error: request for member 'size' in 'res[x2]', which is of non-class type 'int'
   24 |         for(int l=0;l<res[x2].size();l++){
      |                               ^~~~
a.cc:25:22: error: invalid types 'int[int]' for array subscript
   25 |           if((res[x1][k].bit & res[x2][l].bit) != 0) continue;
      |                      ^
a.cc:25:39: error: invalid types 'int[int]' for array subscript
   25 |           if((res[x1][k].bit & res[x2][l].bit) != 0) continue;
      |                                       ^
a.cc:26:11: error: reference to 'data' is ambiguous
   26 |           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:6:8: note:                 'struct data'
    6 | struct data{
      |        ^~~~
a.cc:27:29: error: invalid types 'int[int]' for array subscript
   27 |           double a = res[x2][l].m / (res[x1][k].m + res[x2][l].m);
      |                             ^
a.cc:27:45: error: invalid types 'int[int]' for array subscript
   27 |           double a = res[x2][l].m / (res[x1][k].m + res[x2][l].m);
      |                                             ^
a.cc:27:60: error: invalid types 'int[int]' for array subscript
   27 |           double a = res[x2][l].m / (res[x1][k].m + res[x2][l].m);
      |                                                            ^
a.cc:29:11: error: 'pos' was not declared in this scope
   29 |           pos.lm = min(-a + res[x1][k].lm, b + res[x2][l].lm);
      |           ^~~
a.cc:29:36: error: invalid types 'int[int]' for array subscript
   29 |           pos.lm = min(-a + res[x1][k].lm, b + res[x2][l].lm);
      |                                    ^
a.cc:29:55: error: invalid types 'int[int]' for array subscript
   29 |           pos.lm = min(-a + res[x1][k].lm, b + res[x2][l].lm);
      |                                                       ^
a.cc:30:35: error: invalid types 'int[int]' for array subscript
   30 |           pos.rm = max(b + res[x2][l].rm, -a + res[x1][k].rm);
      |                                   ^
a.cc:30:55: error: invalid types 'int[int]' for array subscript
   30 |           pos.rm = max(b + res[x2][l].rm, -a + res[x1][k].rm);
      |                                                       ^
a.cc:31:26: error: invalid types 'int[int]' for array subscript
   31 |           pos.m = res[x1][k].m + res[x2][l].m;
      |                          ^
a.cc:31:41: error: invalid types 'int[int]' for array subscript
   31 |           pos.m = res[x1][k].m + res[x2][l].m;
      |                                         ^
a.cc:32:28: error: invalid types 'int[int]' for array subscript
   32 |           pos.bit = res[x1][k].bit | res[x2][l].bit;
      |                            ^
a.cc:32:45: error: invalid types 'int[int]' for array subscript
   32 |           pos.bit = res[x1][k].bit | res[x2][l].bit;
      |                                             ^
a.cc:35:23: error: request for member 'push_back' in 'res[i]', which is of non-class type 'int'
   35 |           else res[i].push_back(pos);
      |                       ^~~~~~~~~