#include using namespace std; using Int32 = int_fast32_t; using Word32 = uint_fast32_t; using Int64 = int_fast64_t; using Word64 = uint_fast64_t; using Int128 = __int128_t; using Word128 = __uint128_t; using Int = int_fast64_t; using Word = uint_fast64_t; using F32 = float; using F64 = double; using F80 = long double; using VInt = vector; using VVI = vector; using VWord = vector; using VVW = vector; using VF32 = vector; using VF64 = vector; using VF80 = vector; using VS = vector; using VVS = vector; using VB = vector; using VVB = vector; using PII = pair; using PWW = pair; using VPII = vector; using VPWW = vector; using PQ_PII = priority_queue>; #define SZ(x) ((Int)(x).size()) #define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) #define rep(i,n) for(Int i=0, i##_len=(n); i> v[i]; const Int maxv = 31; Int ans = 10000; for (Int a = 1; a < maxv; a++) { for (Int b = a + 1; b < maxv; b++) { for (Int c = b + 1; c < maxv; c++) { VInt dp(maxv, 10000); dp[0] = 0; for (Int i = 0; i < maxv - a; i++) dp[i + a] = min(dp[i + a], dp[i] + 1); for (Int i = 0; i < maxv - b; i++) dp[i + b] = min(dp[i + b], dp[i] + 1); for (Int i = 0; i < maxv - c; i++) dp[i + c] = min(dp[i + c], dp[i] + 1); ans = min(ans, dp[v[0]] + dp[v[1]] + dp[v[2]] + dp[v[3]]); } } } return 0; }