制約が小さいことに気付くのに時間をかけてしまった。

solution

$A, B, C$に関して総当たりし、それぞれDP。$O((\max V_i)^4)$で間に合う。

$V_0, V_1, V_2, V_3 \le 30$と小さい。 よって$A, B, C \le 30$であり用意する板の種類の選び方は${}_{30}C_3 = 4060$となる。 $A, B, C$が固定されれば$O(\max V_i)$の単純なDPでよい。

implementation

#include <iostream>
#include <algorithm>
#include <array>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < (n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) y) { return (f)(begin(y), end(y), ## __VA_ARGS__); })(x)
typedef long long ll;
using namespace std;
template <class T> void setmin(T & a, T const & b) { if (b < a) a = b; }
const int inf = 1e9+7;
int main() {
    const int MAX = 30;
    int x, y, z, w; cin >> x >> y >> z >> w;
    ll ans = inf;
    repeat (c,MAX+1) {
        repeat (b,c) {
            repeat_from (a,1,b) {
                array<ll,MAX+1> dp; whole(fill, dp, inf);
                dp[0] = 0;
                repeat (i,MAX) {
                    if (i+a < MAX+1) setmin(dp[i+a], dp[i] + 1);
                    if (i+b < MAX+1) setmin(dp[i+b], dp[i] + 1);
                    if (i+c < MAX+1) setmin(dp[i+c], dp[i] + 1);
                }
                setmin(ans, dp[x] + dp[y] + dp[z] + dp[w]);
            }
        }
    }
    cout << ans << endl;
    return 0;
}