8bf237c40d 2011-10-04 kinaba: #include <iostream> 8bf237c40d 2011-10-04 kinaba: #include <sstream> 8bf237c40d 2011-10-04 kinaba: #include <iomanip> 8bf237c40d 2011-10-04 kinaba: #include <vector> 8bf237c40d 2011-10-04 kinaba: #include <string> 8bf237c40d 2011-10-04 kinaba: #include <map> 8bf237c40d 2011-10-04 kinaba: #include <set> 8bf237c40d 2011-10-04 kinaba: #include <algorithm> 8bf237c40d 2011-10-04 kinaba: #include <numeric> 8bf237c40d 2011-10-04 kinaba: #include <iterator> 8bf237c40d 2011-10-04 kinaba: #include <functional> 8bf237c40d 2011-10-04 kinaba: #include <complex> 8bf237c40d 2011-10-04 kinaba: #include <queue> 8bf237c40d 2011-10-04 kinaba: #include <stack> 8bf237c40d 2011-10-04 kinaba: #include <cmath> 8bf237c40d 2011-10-04 kinaba: #include <cassert> 8bf237c40d 2011-10-04 kinaba: #include <cstring> 8bf237c40d 2011-10-04 kinaba: using namespace std; 8bf237c40d 2011-10-04 kinaba: typedef long long LL; 8bf237c40d 2011-10-04 kinaba: typedef complex<double> CMP; 8bf237c40d 2011-10-04 kinaba: 8bf237c40d 2011-10-04 kinaba: class SRMCodingPhase { public: 8bf237c40d 2011-10-04 kinaba: int countScore(vector <int> points, vector <int> skills, int luck) 8bf237c40d 2011-10-04 kinaba: { 8bf237c40d 2011-10-04 kinaba: const int dec[] = {2,4,8}; 8bf237c40d 2011-10-04 kinaba: 8bf237c40d 2011-10-04 kinaba: int pBest = 0; 8bf237c40d 2011-10-04 kinaba: 8bf237c40d 2011-10-04 kinaba: int i[3]; 8bf237c40d 2011-10-04 kinaba: for(i[0]=0; i[0]<skills[0] && i[0]<=luck; ++i[0]) 8bf237c40d 2011-10-04 kinaba: for(i[1]=0; i[1]<skills[1] && i[0]+i[1]<=luck; ++i[1]) 8bf237c40d 2011-10-04 kinaba: for(i[2]=0; i[2]<skills[2] && i[0]+i[1]+i[2]<=luck; ++i[2]) 8bf237c40d 2011-10-04 kinaba: { 8bf237c40d 2011-10-04 kinaba: int a[3]; 8bf237c40d 2011-10-04 kinaba: for(a[0]=0; a[0]<2; ++a[0]) 8bf237c40d 2011-10-04 kinaba: for(a[1]=0; a[1]<2; ++a[1]) 8bf237c40d 2011-10-04 kinaba: for(a[2]=0; a[2]<2; ++a[2]) 8bf237c40d 2011-10-04 kinaba: { 8bf237c40d 2011-10-04 kinaba: int p = 0, t = 0; 8bf237c40d 2011-10-04 kinaba: for(int x=0; x<3; ++x) 8bf237c40d 2011-10-04 kinaba: if( a[x] ) { 8bf237c40d 2011-10-04 kinaba: p += points[x] - dec[x]*(skills[x]-i[x]); 8bf237c40d 2011-10-04 kinaba: t += skills[x]-i[x]; 8bf237c40d 2011-10-04 kinaba: } 8bf237c40d 2011-10-04 kinaba: if( t <= 75 ) 8bf237c40d 2011-10-04 kinaba: pBest = max(pBest, p); 8bf237c40d 2011-10-04 kinaba: } 8bf237c40d 2011-10-04 kinaba: } 8bf237c40d 2011-10-04 kinaba: return pBest; 8bf237c40d 2011-10-04 kinaba: } 8bf237c40d 2011-10-04 kinaba: }; 8bf237c40d 2011-10-04 kinaba: 8bf237c40d 2011-10-04 kinaba: // BEGIN CUT HERE 8bf237c40d 2011-10-04 kinaba: #include <ctime> 8bf237c40d 2011-10-04 kinaba: double start_time; string timer() 8bf237c40d 2011-10-04 kinaba: { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); } 8bf237c40d 2011-10-04 kinaba: template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) 8bf237c40d 2011-10-04 kinaba: { os << "{ "; 8bf237c40d 2011-10-04 kinaba: for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it) 8bf237c40d 2011-10-04 kinaba: os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; } 8bf237c40d 2011-10-04 kinaba: void verify_case(const int& Expected, const int& Received) { 8bf237c40d 2011-10-04 kinaba: bool ok = (Expected == Received); 8bf237c40d 2011-10-04 kinaba: if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl; 8bf237c40d 2011-10-04 kinaba: cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } } 8bf237c40d 2011-10-04 kinaba: #define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock(); 8bf237c40d 2011-10-04 kinaba: #define END verify_case(_, SRMCodingPhase().countScore(points, skills, luck));} 8bf237c40d 2011-10-04 kinaba: int main(){ 8bf237c40d 2011-10-04 kinaba: 8bf237c40d 2011-10-04 kinaba: CASE(0) 8bf237c40d 2011-10-04 kinaba: int points_[] = {250, 500, 1000}; 8bf237c40d 2011-10-04 kinaba: vector <int> points(points_, points_+sizeof(points_)/sizeof(*points_)); 8bf237c40d 2011-10-04 kinaba: int skills_[] = {10, 25, 40}; 8bf237c40d 2011-10-04 kinaba: vector <int> skills(skills_, skills_+sizeof(skills_)/sizeof(*skills_)); 8bf237c40d 2011-10-04 kinaba: int luck = 0; 8bf237c40d 2011-10-04 kinaba: int _ = 1310; 8bf237c40d 2011-10-04 kinaba: END 8bf237c40d 2011-10-04 kinaba: CASE(1) 8bf237c40d 2011-10-04 kinaba: int points_[] = {300, 600, 900}; 8bf237c40d 2011-10-04 kinaba: vector <int> points(points_, points_+sizeof(points_)/sizeof(*points_)); 8bf237c40d 2011-10-04 kinaba: int skills_[] = {30, 65, 90}; 8bf237c40d 2011-10-04 kinaba: vector <int> skills(skills_, skills_+sizeof(skills_)/sizeof(*skills_)); 8bf237c40d 2011-10-04 kinaba: int luck = 25; 8bf237c40d 2011-10-04 kinaba: int _ = 680; 8bf237c40d 2011-10-04 kinaba: END 8bf237c40d 2011-10-04 kinaba: CASE(2) 8bf237c40d 2011-10-04 kinaba: int points_[] = {250, 550, 950}; 8bf237c40d 2011-10-04 kinaba: vector <int> points(points_, points_+sizeof(points_)/sizeof(*points_)); 8bf237c40d 2011-10-04 kinaba: int skills_[] = {10, 25, 40}; 8bf237c40d 2011-10-04 kinaba: vector <int> skills(skills_, skills_+sizeof(skills_)/sizeof(*skills_)); 8bf237c40d 2011-10-04 kinaba: int luck = 75; 8bf237c40d 2011-10-04 kinaba: int _ = 1736; 8bf237c40d 2011-10-04 kinaba: END 8bf237c40d 2011-10-04 kinaba: CASE(3) 8bf237c40d 2011-10-04 kinaba: int points_[] = {256, 512, 1024}; 8bf237c40d 2011-10-04 kinaba: vector <int> points(points_, points_+sizeof(points_)/sizeof(*points_)); 8bf237c40d 2011-10-04 kinaba: int skills_[] = {35, 30, 25}; 8bf237c40d 2011-10-04 kinaba: vector <int> skills(skills_, skills_+sizeof(skills_)/sizeof(*skills_)); 8bf237c40d 2011-10-04 kinaba: int luck = 0; 8bf237c40d 2011-10-04 kinaba: int _ = 1216; 8bf237c40d 2011-10-04 kinaba: END 8bf237c40d 2011-10-04 kinaba: CASE(4) 8bf237c40d 2011-10-04 kinaba: int points_[] = {300, 600, 1100}; 8bf237c40d 2011-10-04 kinaba: vector <int> points(points_, points_+sizeof(points_)/sizeof(*points_)); 8bf237c40d 2011-10-04 kinaba: int skills_[] = {80, 90, 100}; 8bf237c40d 2011-10-04 kinaba: vector <int> skills(skills_, skills_+sizeof(skills_)/sizeof(*skills_)); 8bf237c40d 2011-10-04 kinaba: int luck = 4; 8bf237c40d 2011-10-04 kinaba: int _ = 0; 8bf237c40d 2011-10-04 kinaba: END 8bf237c40d 2011-10-04 kinaba: CASE(5) 8bf237c40d 2011-10-04 kinaba: int points_[] = {300,600,1100}; 8bf237c40d 2011-10-04 kinaba: vector <int> points(points_, points_+sizeof(points_)/sizeof(*points_)); 8bf237c40d 2011-10-04 kinaba: int skills_[] = {30,30,30}; 8bf237c40d 2011-10-04 kinaba: vector <int> skills(skills_, skills_+sizeof(skills_)/sizeof(*skills_)); 8bf237c40d 2011-10-04 kinaba: int luck = 100; 8bf237c40d 2011-10-04 kinaba: int _ = -1; 8bf237c40d 2011-10-04 kinaba: END 8bf237c40d 2011-10-04 kinaba: /* 8bf237c40d 2011-10-04 kinaba: CASE(6) 8bf237c40d 2011-10-04 kinaba: int points_[] = ; 8bf237c40d 2011-10-04 kinaba: vector <int> points(points_, points_+sizeof(points_)/sizeof(*points_)); 8bf237c40d 2011-10-04 kinaba: int skills_[] = ; 8bf237c40d 2011-10-04 kinaba: vector <int> skills(skills_, skills_+sizeof(skills_)/sizeof(*skills_)); 8bf237c40d 2011-10-04 kinaba: int luck = ; 8bf237c40d 2011-10-04 kinaba: int _ = ; 8bf237c40d 2011-10-04 kinaba: END 8bf237c40d 2011-10-04 kinaba: */ 8bf237c40d 2011-10-04 kinaba: } 8bf237c40d 2011-10-04 kinaba: // END CUT HERE