SRM559 Div2 Easy(250) BlockTower
偶偶偶奇奇 という積み方になる。
#include <vector> #include <algorithm> using namespace std; class BlockTower{public: int getTallest( vector <int> blockHeights ) { int n = (int)blockHeights.size(); int ans = 0; for ( int i=0; i<=n; i++ ) { int s = 0; for ( int j=0; j<i; j++ ) if ( blockHeights[j]%2==0 ) s += blockHeights[j]; for ( int j=i; j<n; j++ ) if ( blockHeights[j]%2!=0 ) s += blockHeights[j]; ans = max( ans, s ); } return ans; }};