- 問題文の3つ目のTestCaseが全然通らないのでおかしいなあと色々試行錯誤
- ...
- cCpって何だよ
- 2番目のCは無視すればよい
- 138.30points (31'30'')
- ><
- Passed System Test
class HealthFood {
public:
vector <int> selectMeals(vector <int> protein,
vector <int> carbs,
vector <int> fat,
vector <string> dietPlans) {
int n=sz(dietPlans), m=sz(protein);
vector<int> ans(n);
rep(i,n){
ll p=0,c=0,f=0,t=0;
string dp = dietPlans[i]; // 0-4 [CcPpFfTt]
int dpl=sz(dp);
rep(k,dpl){
ll mag=1LL << ((3-k)*11);
switch(dp[k]){
case 'C': if (!c) c=-mag; break;
case 'c': if (!c) c=mag; break;
case 'P': if (!p) p=-mag; break;
case 'p': if (!p) p=mag; break;
case 'F': if (!f) f=-mag; break;
case 'f': if (!f) f=mag; break;
case 'T': if (!t) t=-mag; break;
case 't': if (!t) t=mag; break;
}
}
vector<pair<ll,int> > pt(m);
rep(j,m){
int calories=9*fat[j] + 5*(protein[j] + carbs[j]); // 1400 < 2048
ll score = c*carbs[j] + p*protein[j] + f*fat[j] + t*calories;
pt[j] = make_pair(score,j);
}
sort(all(pt));
ans[i] = pt[0].second;
}
return ans;
}
};