Language: C++

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
vector<int> m = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int getmax(string a, string b)
{
  if(a.size() != b.size())
  {
    return a.size() > b.size() ? a : b;
  }
  return a > b ? a : b;
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(m, 0);
    for(int i = 0; i < m; i++)
    {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int>);
    vector<string> dp(max(n + 1, 10), "");
    for(int i = 0; i < m, i++)
    {
        dp[m[a[i]]] = getmax(dp[m[a[i]]], to_string(a[i]));
    }
    
    for(int j = 0; j < n; j++)
    {
        for(int i = 0; i < m; i++)
        {
            if(j - m[a[i]] >= 0 && dp[j - m[a[i]] != "")
            {
                dp[j] = getmax(dp[j], dp[j - m[a[i]] + to_string(a[i]));
            }
        }
    }
    cout << dp[n];
    
    return 0;
}


Compiler output:
a.cc: In function 'int getmax(std::string, std::string)':
a.cc:11:32: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'int' in return
   11 |     return a.size() > b.size() ? a : b;
      |            ~~~~~~~~~~~~~~~~~~~~^~~~~~~
      |                                |
      |                                std::string {aka std::__cxx11::basic_string<char>}
a.cc:13:16: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'int' in return
   13 |   return a > b ? a : b;
      |          ~~~~~~^~~~~~~
      |                |
      |                std::string {aka std::__cxx11::basic_string<char>}
a.cc: In function 'int main()':
a.cc:25:42: error: expected primary-expression before ')' token
   25 |     sort(a.begin(), a.end(), greater<int>);
      |                                          ^
a.cc:27:30: error: expected ';' before ')' token
   27 |     for(int i = 0; i < m, i++)
      |                              ^
      |                              ;
a.cc:29:13: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   29 |         dp[m[a[i]]] = getmax(dp[m[a[i]]], to_string(a[i]));
      |             ^
a.cc:29:34: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   29 |         dp[m[a[i]]] = getmax(dp[m[a[i]]], to_string(a[i]));
      |                                  ^
a.cc:36:21: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   36 |             if(j - m[a[i]] >= 0 && dp[j - m[a[i]] != "")
      |                     ^
a.cc:36:44: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   36 |             if(j - m[a[i]] >= 0 && dp[j - m[a[i]] != "")
      |                                            ^
a.cc:36:56: error: expected ']' before ')' token
   36 |             if(j - m[a[i]] >= 0 && dp[j - m[a[i]] != "")
      |                                                        ^
      |                                                        ]
a.cc:38:47: error: invalid types 'int[__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}]' for array subscript
   38 |                 dp[j] = getmax(dp[j], dp[j - m[a[i]] + to_string(a[i]));
      |                                               ^
a.cc:38:71: error: expected ']' before ')' token
   38 |                 dp[j] = getmax(dp[j], dp[j - m[a[i]] + to_string(a[i]));
      |                                                                       ^
      |                                                                       ]