#include #include #include using namespace std; #define VMAX 1500 #define CMAX 300 #define NMAX 50 typedef struct S{ int T,Y,M; } s; typedef struct S2{ int C,ed; } s2; int main(){ int N,C,V; int S[VMAX],T[VMAX],Y[VMAX],M[VMAX]; vector vs[NMAX+1]; int ansmap[NMAX+1][CMAX+1]; queue qs; cin>>N; cin>>C; cin>>V; for(int i=0;i>S[i]; for(int i=0;i>T[i]; for(int i=0;i>Y[i]; for(int i=0;i>M[i]; for(int i=0;i=0){ int yM=ansmap[vT][nC-vY]; if(yM==-1||yM>nM+vM){ ansmap[vT][nC-vY]=nM+vM; stmp2.C=nC-vY; stmp2.ed=vT; qs.push(stmp2); } } } } int ans=-1; for(int i=0;i<=C;i++){ if(ansmap[N][i]!=-1){ if(ans==-1||ansmap[N][i]