SRM522 Div2 Easy(250) PointErasingTwo
#include <vector> using namespace std; class PointErasingTwo{public: int getMaximum( vector <int> y ) { int n = (int)y.size(); int ans = 0; for ( int x1=0; x1<n; x1++ ) for ( int x2=x1+1; x2<n; x2++ ) if ( y[x1]!=y[x2] ) { int c = 0; for ( int x=x1+1; x<=x2-1; x++ ) if ( min(y[x1],y[x2])<y[x] && y[x]<max(y[x1],y[x2]) ) c++; ans = max( ans, c ); } return ans; }};