Language: C++

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

const int INF = 1<<29;

//dpテーブル
int dp[1000][1010];

int calc_mp(int x,int N, int* Len){
  //dpテーブルの初期化
  for (int i = 0; i < 1000; i++) for (int j = 0; j < 1010; j++) dp[i][j] = INF;
  for (int i = 0; i < 1000; i++) for (int k = 0; k < N; k++) dp[i][Len[k]] = 0;

  for (int i = 0; i < 1000; i++){
    for (int l = 0; l < 1010; l++){
      if (l != x){
        if (l >= Len[7]) dp[i+1][l] = min(dp[i][l-1]+1, dp[i][l+1]+1, dp[i][l-Len[7]]+10, dp[i][l-Len[6]]+10, dp[i][l-Len[5]]+10, dp[i][l-Len[4]]+10, dp[i][l-Len[3]]+10, dp[i][l-Len[2]]+10, dp[i][l-Len[1]]+10, dp[i][l-Len[0]]+10);
        else if (l >= Len[6] && l < Len[7]) dp[i+1][l] = min(dp[i][l-1]+1, dp[i][l+1]+1, dp[i][l-Len[6]]+10, dp[i][l-Len[5]]+10, dp[i][l-Len[4]]+10, dp[i][l-Len[3]]+10, dp[i][l-Len[2]]+10, dp[i][l-Len[1]]+10, dp[i][l-Len[0]]+10);
        else if (l >= Len[5] && l < Len[6]) dp[i+1][l] = min(dp[i][l-1]+1, dp[i][l+1]+1, dp[i][l-Len[5]]+10, dp[i][l-Len[4]]+10, dp[i][l-Len[3]]+10, dp[i][l-Len[2]]+10, dp[i][l-Len[1]]+10, dp[i][l-Len[0]]+10);
        else if (l >= Len[4] && l < Len[5]) dp[i+1][l] = min(dp[i][l-1]+1, dp[i][l+1]+1, dp[i][l-Len[4]]+10, dp[i][l-Len[3]]+10, dp[i][l-Len[2]]+10, dp[i][l-Len[1]]+10, dp[i][l-Len[0]]+10);
        else if (l >= Len[3] && l < Len[4]) dp[i+1][l] = min(dp[i][l-1]+1, dp[i][l+1]+1, dp[i][l-Len[3]]+10, dp[i][l-Len[2]]+10, dp[i][l-Len[1]]+10, dp[i][l-Len[0]]+10);
        else if (l >= Len[2] && l < Len[3]) dp[i+1][l] = min(dp[i][l-1]+1, dp[i][l+1]+1, dp[i][l-Len[2]]+10, dp[i][l-Len[1]]+10, dp[i][l-Len[0]]+10);
        else if (l >= Len[1] && l < Len[2]) dp[i+1][l] = min(dp[i][l-1]+1, dp[i][l+1]+1, dp[i][l-Len[1]]+10, dp[i][l-Len[0]]+10);
        else if (l >= Len[0] && l < Len[1]) dp[i+1][l] = min(dp[i][l-1]+1, dp[i][l+1]+1, dp[i][l-Len[0]]+10);        
        else dp[i+1][l] = min(dp[i][l-1]+1, dp[i][l+1]+1);
      }
      else dp[i+1][l] = dp[i][l];
    }
  }
  return dp[999][x];
}

int main(){
  //入力
  int N;
  cin >> N;
  vector<int> ABC;
  for (int i = 0; i < 3; i++) cin >> ABC.at(i);
  vector<int> Len(8);
  for (int j = 0; j < N; j++) cin >> Len[j];

  sort(Len.begin(),Len.end());

  cout >> calc_mp(ABC.at(0),N,Len.data()) + calc_mp(ABC.at(1),N,Len.data()) + calc_mp(ABC.at(2),N,Len.data()) >> endl;
}

Compiler output:
a.cc: In function 'int calc_mp(int, int, int*)':
a.cc:19:42: error: no matching function for call to 'min(int, int, int, int, int, int, int, int, int, int)'
   19 |         if (l >= Len[7]) dp[i+1][l] = min(dp[i][l-1]+1, dp[i][l+1]+1, dp[i][l-Len[7]]+10, dp[i][l-Len[6]]+10, dp[i][l-Len[5]]+10, dp[i][l-Len[4]]+10, dp[i][l-Len[3]]+10, dp[i][l-Len[2]]+10, dp[i][l-Len[1]]+10, dp[i][l-Len[0]]+10);
      |                                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 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/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 10 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 10 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 10 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   candidate expects 2 arguments, 10 provided
a.cc:20:61: error: no matching function for call to 'min(int, int, int, int, int, int, int, int, int)'
   20 |         else if (l >= Len[6] && l < Len[7]) dp[i+1][l] = min(dp[i][l-1]+1, dp[i][l+1]+1, dp[i][l-Len[6]]+10, dp[i][l-Len[5]]+10, dp[i][l-Len[4]]+10, dp[i][l-Len[3]]+10, dp[i][l-Len[2]]+10, dp[i][l-Len[1]]+10, dp[i][l-Len[0]]+10);
      |                                                          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 9 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 9 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 9 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   candidate expects 2 arguments, 9 provided
a.cc:21:61: error: no matching function for call to 'min(int, int, int, int, int, int, int, int)'
   21 |         else if (l >= Len[5] && l < Len[6]) dp[i+1][l] = min(dp[i][l-1]+1, dp[i][l+1]+1, dp[i][l-Len[5]]+10, dp[i][l-Len[4]]+10, dp[i][l-Len[3]]+10, dp[i][l-Len[2]]+10, dp[i][l-Len[1]]+10, dp[i][l-Len[0]]+10);
      |                                                          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 8 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 8 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 8 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   candidate expects 2 arguments, 8 provided
a.cc:22:61: error: no matching function for call to 'min(int, int, int, int, int, int, int)'
   22 |         else if (l >= Len[4] && l < Len[5]) dp[i+1][l] = min(dp[i][l-1]+1, dp[i][l+1]+1, dp[i][l-Len[4]]+10, dp[i][l-Len[3]]+10, dp[i][l-Len[2]]+10, dp[i][l-Len[1]]+10, dp[i][l-Len[0]]+10);
      |                                                          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 7 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 7 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 7 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   candidate expects 2 arguments, 7 provided
a.cc:23:61: error: no matching function for call to 'min(int, int, int, int, int, int)'
   23 |         else if (l >= Len[3] && l < Len[4]) dp[i+1][l] = min(dp[i][l-1]+1, dp[i][l+1]+1, dp[i][l-Len[3]]+10, dp[i][l-Len[2]]+10, dp[i][l-Len[1]]+10, dp[i][l-Len[0]]+10);
      |                                                          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 6 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 6 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 6 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   candidate expects 2 arguments, 6 provided
a.cc:24:61: error: no matching function for call to 'min(int, int, int, int, int)'
   24 |         else if (l >= Len[2] && l < Len[3]) dp[i+1][l] = min(dp[i][l-1]+1, dp[i][l+1]+1, dp[i][l-Len[2]]+10, dp[i][l-Len[1]]+10, dp[i][l-Len[0]]+10);
      |                                                          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 5 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const