5aef274bd6 2011-11-12 kinaba: #include <iostream> 5aef274bd6 2011-11-12 kinaba: #include <sstream> 5aef274bd6 2011-11-12 kinaba: #include <iomanip> 5aef274bd6 2011-11-12 kinaba: #include <vector> 5aef274bd6 2011-11-12 kinaba: #include <string> 5aef274bd6 2011-11-12 kinaba: #include <map> 5aef274bd6 2011-11-12 kinaba: #include <set> 5aef274bd6 2011-11-12 kinaba: #include <algorithm> 5aef274bd6 2011-11-12 kinaba: #include <numeric> 5aef274bd6 2011-11-12 kinaba: #include <iterator> 5aef274bd6 2011-11-12 kinaba: #include <functional> 5aef274bd6 2011-11-12 kinaba: #include <complex> 5aef274bd6 2011-11-12 kinaba: #include <queue> 5aef274bd6 2011-11-12 kinaba: #include <stack> 5aef274bd6 2011-11-12 kinaba: #include <cmath> 5aef274bd6 2011-11-12 kinaba: #include <cassert> 5aef274bd6 2011-11-12 kinaba: #include <cstring> 5aef274bd6 2011-11-12 kinaba: using namespace std; 5aef274bd6 2011-11-12 kinaba: typedef long long LL; 5aef274bd6 2011-11-12 kinaba: typedef complex<double> CMP; 5aef274bd6 2011-11-12 kinaba: 5aef274bd6 2011-11-12 kinaba: class PointErasingTwo { public: 5aef274bd6 2011-11-12 kinaba: int getMaximum(vector <int> y) 5aef274bd6 2011-11-12 kinaba: { 5aef274bd6 2011-11-12 kinaba: int ans = 0; 5aef274bd6 2011-11-12 kinaba: for(int i=0; i<y.size(); ++i) 5aef274bd6 2011-11-12 kinaba: for (int j = i+1; j < y.size(); j++) 5aef274bd6 2011-11-12 kinaba: { 5aef274bd6 2011-11-12 kinaba: if(y[i] != y[j]) { 5aef274bd6 2011-11-12 kinaba: int er = 0; 5aef274bd6 2011-11-12 kinaba: for (int k = i+1; k < j; k++) 5aef274bd6 2011-11-12 kinaba: if( min(y[i],y[j])<y[k] && y[k]<max(y[i],y[j]) ) 5aef274bd6 2011-11-12 kinaba: ++er; 5aef274bd6 2011-11-12 kinaba: ans = max(ans, er); 5aef274bd6 2011-11-12 kinaba: } 5aef274bd6 2011-11-12 kinaba: } 5aef274bd6 2011-11-12 kinaba: return ans; 5aef274bd6 2011-11-12 kinaba: } 5aef274bd6 2011-11-12 kinaba: }; 5aef274bd6 2011-11-12 kinaba: 5aef274bd6 2011-11-12 kinaba: // BEGIN CUT HERE 5aef274bd6 2011-11-12 kinaba: #include <ctime> 5aef274bd6 2011-11-12 kinaba: double start_time; string timer() 5aef274bd6 2011-11-12 kinaba: { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); } 5aef274bd6 2011-11-12 kinaba: template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) 5aef274bd6 2011-11-12 kinaba: { os << "{ "; 5aef274bd6 2011-11-12 kinaba: for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it) 5aef274bd6 2011-11-12 kinaba: os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; } 5aef274bd6 2011-11-12 kinaba: void verify_case(const int& Expected, const int& Received) { 5aef274bd6 2011-11-12 kinaba: bool ok = (Expected == Received); 5aef274bd6 2011-11-12 kinaba: if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl; 5aef274bd6 2011-11-12 kinaba: cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } } 5aef274bd6 2011-11-12 kinaba: #define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock(); 5aef274bd6 2011-11-12 kinaba: #define END verify_case(_, PointErasingTwo().getMaximum(y));} 5aef274bd6 2011-11-12 kinaba: int main(){ 5aef274bd6 2011-11-12 kinaba: 5aef274bd6 2011-11-12 kinaba: CASE(0) 5aef274bd6 2011-11-12 kinaba: int y_[] = { 1, 2, 1, 1, 0, 4, 3 }; 5aef274bd6 2011-11-12 kinaba: vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 5aef274bd6 2011-11-12 kinaba: int _ = 2; 5aef274bd6 2011-11-12 kinaba: END 5aef274bd6 2011-11-12 kinaba: CASE(1) 5aef274bd6 2011-11-12 kinaba: int y_[] = { 0, 1 }; 5aef274bd6 2011-11-12 kinaba: vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 5aef274bd6 2011-11-12 kinaba: int _ = 0; 5aef274bd6 2011-11-12 kinaba: END 5aef274bd6 2011-11-12 kinaba: CASE(2) 5aef274bd6 2011-11-12 kinaba: int y_[] = { 0, 1, 2, 3, 4 }; 5aef274bd6 2011-11-12 kinaba: vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 5aef274bd6 2011-11-12 kinaba: int _ = 3; 5aef274bd6 2011-11-12 kinaba: END 5aef274bd6 2011-11-12 kinaba: CASE(3) 5aef274bd6 2011-11-12 kinaba: int y_[] = { 10, 19, 10, 19 }; 5aef274bd6 2011-11-12 kinaba: vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 5aef274bd6 2011-11-12 kinaba: int _ = 0; 5aef274bd6 2011-11-12 kinaba: END 5aef274bd6 2011-11-12 kinaba: CASE(4) 5aef274bd6 2011-11-12 kinaba: int y_[] = { 0, 23, 49, 50, 32, 0, 18, 50, 0, 28, 50, 27, 49, 0 }; 5aef274bd6 2011-11-12 kinaba: vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 5aef274bd6 2011-11-12 kinaba: int _ = 5; 5aef274bd6 2011-11-12 kinaba: END 5aef274bd6 2011-11-12 kinaba: /* 5aef274bd6 2011-11-12 kinaba: CASE(5) 5aef274bd6 2011-11-12 kinaba: int y_[] = ; 5aef274bd6 2011-11-12 kinaba: vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 5aef274bd6 2011-11-12 kinaba: int _ = ; 5aef274bd6 2011-11-12 kinaba: END 5aef274bd6 2011-11-12 kinaba: CASE(6) 5aef274bd6 2011-11-12 kinaba: int y_[] = ; 5aef274bd6 2011-11-12 kinaba: vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 5aef274bd6 2011-11-12 kinaba: int _ = ; 5aef274bd6 2011-11-12 kinaba: END 5aef274bd6 2011-11-12 kinaba: */ 5aef274bd6 2011-11-12 kinaba: } 5aef274bd6 2011-11-12 kinaba: // END CUT HERE