#include using namespace std; const int MAXB = 150; // number of storage bins const int NUMC = 5; // number of companies const int EMPTY = -1; const int INF = 1000000000; int bins[MAXB]; int weights[MAXB] = {0}; int totalWeights[NUMC] = {0}; // total weights for all bins for a company int counts[NUMC] = {0}; // number of each company in final bins int first[NUMC], last [NUMC]; // location of first and last company bin prior to moving int costs[NUMC][MAXB]; // costs[i][j] = cost for company i's bins to start at location j int bestCost = INF; // optimal cost of moving bins int calcCost(int comp, int bin, int nBins) { if (bin + counts[comp] >nBins) return INF; int ans = totalWeights[comp]; for(int b=bin; b= bestCost) return; if (comp == NUMC) { if (currCost < bestCost) { bestCost = currCost; } return; } for(int b=0; b<=nBins-counts[comp]; b++) { if (okToPlace(counts[comp], b, placed)) { for(int i=0; i> s; n = s.length(); for(int i=0; i> weights[i]; switch (s[i]) { case 'A' : bins[i] = 0; counts[0]++; totalWeights[0] += weights[i]; break; case 'E' : bins[i] = 1; counts[1]++; totalWeights[1] += weights[i]; break; case 'I' : bins[i] = 2; counts[2]++; totalWeights[2] += weights[i]; break; case 'O' : bins[i] = 3; counts[3]++; totalWeights[3] += weights[i]; break; case 'U' : bins[i] = 4; totalWeights[4] += weights[i]; counts[4]++; break; default : bins[i] = EMPTY; } } cin >> m; for(int i=0; i> b; b--; counts[bins[b]]--; totalWeights[bins[b]] -= weights[b]; bins[b] = EMPTY; weights[b] = 0; } /* for(int i=0; i> s; for(int i=0; i