解いた問題

3/20/2012

SRM520 Div1 Easy

250
全部試す。
  1. class SRMCodingPhase {  
  2. public:  
  3.   int countScore(vector <int> P, vector <int> S, int L)  
  4.   {  
  5.     int mx = 0;  
  6.   
  7.     for (int a = 0; a < S[0]; ++a) {  
  8.       for (int b = 0; b < S[1]; ++b) {  
  9.         for (int c = 0; c < S[2]; ++c) {  
  10.           if (a + b + c <= L) ; else break;  
  11.           vector<int> s;  
  12.           s.push_back(S[0] - a);  
  13.           s.push_back(S[1] - b);  
  14.           s.push_back(S[2] - c);  
  15.           int ord[] = {0, 1, 2};  
  16.           do {  
  17.             int p = 0, t = 0;  
  18.             for (int i = 0; i < 3; ++i) {  
  19.               t += s[ord[i]];  
  20.               if (t <= 75) ; else break;  
  21.               int lost = (1 << (ord[i] + 1)) * s[ord[i]];  
  22.               p += max(0, P[ord[i]] - lost);  
  23.             }  
  24.             mx = max(mx, p);  
  25.           } while (next_permutation(ord, ord + 3));  
  26.         }  
  27.       }  
  28.     }  
  29.   
  30.     return mx;  
  31.   }  
  32. };  

0 件のコメント :

コメントを投稿