# Include <stdio. h> # include <string. h> # define min (a, B) a <B? A: B const int maxn = 115; const int INF = 1000000000; int f [maxn] [maxn]; // f [I] [j] indicates the minimum time consumed when the I-th stage consumes j points. Int main () {int I, j, t, n, m, t1, t2, t3, f1, f2; scanf ("% d", & t ); while (t --) {scanf ("% d", & n, & m); for (I = 0; I <= n; I ++) for (j = 0; j <= m; j ++) f [I] [j] = INF; f [0] [m] = 0; for (I = 1; I <= n; I ++) {scanf ("% d", & t1, & t2, & t3, & f1, & f2); for (j = 0; j <= m; j ++) {if (j> = f1) f [I] [j-f1] = min (f [I] [j-f1], f [I-1] [j] + t1 ); f [I] [j] = min (f [I] [j], f [I-1] [j] + t2); if (j + f 2 <= m) f [I] [j + f2] = min (f [I] [j + f2], f [I-1] [j] + t3 ); else f [I] [m] = min (f [I] [m], f [I-1] [j] + t3) ;}} int minn = INF; for (I = 0; I <= m; I ++) if (f [n] [I] <minn) minn = f [n] [I]; printf ("% d \ n", minn) ;}return 0 ;}# include <stdio. h> # include <string. h> # define min (a, B) a <B? A: bconst int maxn = 115; const int INF = 1000000000; int f [maxn] [maxn]; // f [I] [j] indicates the minimum time consumed when the I-th stage consumes j points. Int main () {int I, j, t, n, m, t1, t2, t3, f1, f2; scanf ("% d", & t ); while (t --) {scanf ("% d", & n, & m); for (I = 0; I <= n; I ++) for (j = 0; j <= m; j ++) f [I] [j] = INF; f [0] [m] = 0; for (I = 1; I <= n; I ++) {scanf ("% d", & t1, & t2, & t3, & f1, & f2); for (j = 0; j <= m; j ++) {if (j> = f1) f [I] [j-f1] = min (f [I] [j-f1], f [I-1] [j] + t1 ); f [I] [j] = min (f [I] [j], f [I-1] [j] + t2); if (j + f2 <= m) f [I] [j + f2] = min (f [I] [j + f2], f [I-1] [j] + t3 ); else f [I] [m] = min (f [I] [m], f [I-1] [j] + t3) ;}} int minn = INF; for (I = 0; I <= m; I ++) if (f [n] [I] <minn) minn = f [n] [I]; printf ("% d \ n", minn);} return 0 ;}