#include using namespace std; #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) #define unless(p) if(!(p)) #define until(p) while(!(p)) using ll = long long; using P = std::tuple; const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1}; int N, C; int L[60], W[60]; int dp[60][60][60]; // 残金, 2つ前, 1つ前 bool isKadomatsu(int i, int j, int k){ int s = std::min({L[i], L[j], L[k]}), u = std::max({L[i], L[j], L[k]}), t = (L[i] + L[j] + L[k]) - (s + u); return s != t && t != u && (L[j] == s || L[j] == u); } int rec(int rem, int p2, int p1){ if(dp[rem][p2][p1] != -1){ return dp[rem][p2][p1]; } int mx = 0; for(int i=0;i> N >> C; for(int i=0;i> L[i]; } for(int i=0;i> W[i]; } memset(dp, -1, sizeof(dp)); int res = 0; for(int i=0;i