classSolution{public:intperfectMenu(vector<int>& materials, vector<vector<int>>& cookbooks, vector<vector<int>>& attribute,int limit){int n = cookbooks.size();int ans =-1;for(int i =1; i <(1<<n);++i){int full =0, deli =0;vector<int>cost(5,0);bool ok =true;for(int j =0; j < n;++j){if((i>>j)&1)// i 狀態哪些位是 1{for(int k =0; k <5;++k){// 花費的食材累加cost[k]+= cookbooks[j][k];if(cost[k]> materials[k]){// 超過食材限度ok =false;break;}}full += attribute[j][1];// 飽腹感deli += attribute[j][0];// 美味度}if(!ok)break;}if(ok && full >= limit){ans =max(ans, deli);}}return ans;}};