全部試す。
class SRMCodingPhase { public: int countScore(vector <int> P, vector <int> S, int L) { int mx = 0; for (int a = 0; a < S[0]; ++a) { for (int b = 0; b < S[1]; ++b) { for (int c = 0; c < S[2]; ++c) { if (a + b + c <= L) ; else break; vector<int> s; s.push_back(S[0] - a); s.push_back(S[1] - b); s.push_back(S[2] - c); int ord[] = {0, 1, 2}; do { int p = 0, t = 0; for (int i = 0; i < 3; ++i) { t += s[ord[i]]; if (t <= 75) ; else break; int lost = (1 << (ord[i] + 1)) * s[ord[i]]; p += max(0, P[ord[i]] - lost); } mx = max(mx, p); } while (next_permutation(ord, ord + 3)); } } } return mx; } };
0 件のコメント :
コメントを投稿