9b83877d51 2014-05-20 kinaba: #include <iostream> 9b83877d51 2014-05-20 kinaba: #include <sstream> 9b83877d51 2014-05-20 kinaba: #include <iomanip> 9b83877d51 2014-05-20 kinaba: #include <vector> 9b83877d51 2014-05-20 kinaba: #include <string> 9b83877d51 2014-05-20 kinaba: #include <map> 9b83877d51 2014-05-20 kinaba: #include <set> 9b83877d51 2014-05-20 kinaba: #include <algorithm> 9b83877d51 2014-05-20 kinaba: #include <numeric> 9b83877d51 2014-05-20 kinaba: #include <iterator> 9b83877d51 2014-05-20 kinaba: #include <functional> 9b83877d51 2014-05-20 kinaba: #include <complex> 9b83877d51 2014-05-20 kinaba: #include <queue> 9b83877d51 2014-05-20 kinaba: #include <stack> 9b83877d51 2014-05-20 kinaba: #include <cmath> 9b83877d51 2014-05-20 kinaba: #include <cassert> 9b83877d51 2014-05-20 kinaba: #include <tuple> 9b83877d51 2014-05-20 kinaba: using namespace std; 9b83877d51 2014-05-20 kinaba: typedef long long LL; 9b83877d51 2014-05-20 kinaba: typedef complex<double> CMP; 9b83877d51 2014-05-20 kinaba: 9b83877d51 2014-05-20 kinaba: class SixteenBricks { public: 9b83877d51 2014-05-20 kinaba: int maximumSurface(vector <int> height) 9b83877d51 2014-05-20 kinaba: { 9b83877d51 2014-05-20 kinaba: sort(height.begin(), height.end()); 9b83877d51 2014-05-20 kinaba: int total = accumulate(height.begin(), height.end(), 0) * 4 + 16; 9b83877d51 2014-05-20 kinaba: 9b83877d51 2014-05-20 kinaba: total -= height[0] * 4 * 2; 9b83877d51 2014-05-20 kinaba: total -= height[1] * 4 * 2; 9b83877d51 2014-05-20 kinaba: total -= height[2] * 3 * 2; 9b83877d51 2014-05-20 kinaba: total -= height[3] * 3 * 2; 9b83877d51 2014-05-20 kinaba: total -= height[4] * 3 * 2; 9b83877d51 2014-05-20 kinaba: total -= height[5] * 3 * 2; 9b83877d51 2014-05-20 kinaba: total -= height[6] * 2 * 2; 9b83877d51 2014-05-20 kinaba: total -= height[7] * 2 * 2; 9b83877d51 2014-05-20 kinaba: return total; 9b83877d51 2014-05-20 kinaba: } 9b83877d51 2014-05-20 kinaba: }; 9b83877d51 2014-05-20 kinaba: 9b83877d51 2014-05-20 kinaba: // BEGIN CUT HERE 9b83877d51 2014-05-20 kinaba: #include <ctime> 9b83877d51 2014-05-20 kinaba: double start_time; string timer() 9b83877d51 2014-05-20 kinaba: { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); } 9b83877d51 2014-05-20 kinaba: template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) 9b83877d51 2014-05-20 kinaba: { os << "{ "; 9b83877d51 2014-05-20 kinaba: for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it) 9b83877d51 2014-05-20 kinaba: os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; } 9b83877d51 2014-05-20 kinaba: void verify_case(const int& Expected, const int& Received) { 9b83877d51 2014-05-20 kinaba: bool ok = (Expected == Received); 9b83877d51 2014-05-20 kinaba: if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl; 9b83877d51 2014-05-20 kinaba: cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } } 9b83877d51 2014-05-20 kinaba: #define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock(); 9b83877d51 2014-05-20 kinaba: #define END verify_case(_, SixteenBricks().maximumSurface(height));} 9b83877d51 2014-05-20 kinaba: int main(){ 9b83877d51 2014-05-20 kinaba: 9b83877d51 2014-05-20 kinaba: CASE(0) 9b83877d51 2014-05-20 kinaba: int height_[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; 9b83877d51 2014-05-20 kinaba: vector <int> height(height_, height_+sizeof(height_)/sizeof(*height_)); 9b83877d51 2014-05-20 kinaba: int _ = 32; 9b83877d51 2014-05-20 kinaba: END 9b83877d51 2014-05-20 kinaba: CASE(1) 9b83877d51 2014-05-20 kinaba: int height_[] = {1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2}; 9b83877d51 2014-05-20 kinaba: vector <int> height(height_, height_+sizeof(height_)/sizeof(*height_)); 9b83877d51 2014-05-20 kinaba: int _ = 64; 9b83877d51 2014-05-20 kinaba: END 9b83877d51 2014-05-20 kinaba: CASE(2) 9b83877d51 2014-05-20 kinaba: int height_[] = {77, 78, 58, 34, 30, 20, 8, 71, 37, 74, 21, 45, 39, 16, 4, 59} 9b83877d51 2014-05-20 kinaba: ; 9b83877d51 2014-05-20 kinaba: vector <int> height(height_, height_+sizeof(height_)/sizeof(*height_)); 9b83877d51 2014-05-20 kinaba: int _ = 1798; 9b83877d51 2014-05-20 kinaba: END 9b83877d51 2014-05-20 kinaba: /* 9b83877d51 2014-05-20 kinaba: CASE(3) 9b83877d51 2014-05-20 kinaba: int height_[] = ; 9b83877d51 2014-05-20 kinaba: vector <int> height(height_, height_+sizeof(height_)/sizeof(*height_)); 9b83877d51 2014-05-20 kinaba: int _ = ; 9b83877d51 2014-05-20 kinaba: END 9b83877d51 2014-05-20 kinaba: CASE(4) 9b83877d51 2014-05-20 kinaba: int height_[] = ; 9b83877d51 2014-05-20 kinaba: vector <int> height(height_, height_+sizeof(height_)/sizeof(*height_)); 9b83877d51 2014-05-20 kinaba: int _ = ; 9b83877d51 2014-05-20 kinaba: END 9b83877d51 2014-05-20 kinaba: */ 9b83877d51 2014-05-20 kinaba: } 9b83877d51 2014-05-20 kinaba: // END CUT HERE