6b700c1e67 2013-06-04 kinaba: #include <iostream> 6b700c1e67 2013-06-04 kinaba: #include <sstream> 6b700c1e67 2013-06-04 kinaba: #include <iomanip> 6b700c1e67 2013-06-04 kinaba: #include <vector> 6b700c1e67 2013-06-04 kinaba: #include <string> 6b700c1e67 2013-06-04 kinaba: #include <map> 6b700c1e67 2013-06-04 kinaba: #include <set> 6b700c1e67 2013-06-04 kinaba: #include <algorithm> 6b700c1e67 2013-06-04 kinaba: #include <numeric> 6b700c1e67 2013-06-04 kinaba: #include <iterator> 6b700c1e67 2013-06-04 kinaba: #include <functional> 6b700c1e67 2013-06-04 kinaba: #include <complex> 6b700c1e67 2013-06-04 kinaba: #include <queue> 6b700c1e67 2013-06-04 kinaba: #include <stack> 6b700c1e67 2013-06-04 kinaba: #include <cmath> 6b700c1e67 2013-06-04 kinaba: #include <cassert> 6b700c1e67 2013-06-04 kinaba: using namespace std; 6b700c1e67 2013-06-04 kinaba: typedef long long LL; 6b700c1e67 2013-06-04 kinaba: typedef long double LD; 6b700c1e67 2013-06-04 kinaba: typedef complex<double> CMP; 6b700c1e67 2013-06-04 kinaba: 6b700c1e67 2013-06-04 kinaba: class EelAndRabbit { public: 6b700c1e67 2013-06-04 kinaba: int getmax(vector <int> l, vector <int> t) 6b700c1e67 2013-06-04 kinaba: { 6b700c1e67 2013-06-04 kinaba: const int N = l.size(); 6b700c1e67 2013-06-04 kinaba: 6b700c1e67 2013-06-04 kinaba: vector<int> ps; 6b700c1e67 2013-06-04 kinaba: for(int i=0; i<N; ++i) { 6b700c1e67 2013-06-04 kinaba: ps.push_back(t[i]); 6b700c1e67 2013-06-04 kinaba: ps.push_back(t[i]+l[i]); 6b700c1e67 2013-06-04 kinaba: } 6b700c1e67 2013-06-04 kinaba: 6b700c1e67 2013-06-04 kinaba: int best = 0; 6b700c1e67 2013-06-04 kinaba: for(int i=0; i<ps.size(); ++i) 6b700c1e67 2013-06-04 kinaba: for(int k=0; k<ps.size(); ++k) { 6b700c1e67 2013-06-04 kinaba: int p = ps[i], q = ps[k]; 6b700c1e67 2013-06-04 kinaba: int cat = 0; 6b700c1e67 2013-06-04 kinaba: for(int x=0; x<N; ++x) 6b700c1e67 2013-06-04 kinaba: { 6b700c1e67 2013-06-04 kinaba: if(t[x]<=p && p<=t[x]+l[x] 6b700c1e67 2013-06-04 kinaba: || t[x]<=q && q<=t[x]+l[x]) 6b700c1e67 2013-06-04 kinaba: ++cat; 6b700c1e67 2013-06-04 kinaba: } 6b700c1e67 2013-06-04 kinaba: best = max(best, cat); 6b700c1e67 2013-06-04 kinaba: } 6b700c1e67 2013-06-04 kinaba: return best; 6b700c1e67 2013-06-04 kinaba: } 6b700c1e67 2013-06-04 kinaba: }; 6b700c1e67 2013-06-04 kinaba: 6b700c1e67 2013-06-04 kinaba: // BEGIN CUT HERE 6b700c1e67 2013-06-04 kinaba: #include <ctime> 6b700c1e67 2013-06-04 kinaba: double start_time; string timer() 6b700c1e67 2013-06-04 kinaba: { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); } 6b700c1e67 2013-06-04 kinaba: template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) 6b700c1e67 2013-06-04 kinaba: { os << "{ "; 6b700c1e67 2013-06-04 kinaba: for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it) 6b700c1e67 2013-06-04 kinaba: os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; } 6b700c1e67 2013-06-04 kinaba: void verify_case(const int& Expected, const int& Received) { 6b700c1e67 2013-06-04 kinaba: bool ok = (Expected == Received); 6b700c1e67 2013-06-04 kinaba: if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl; 6b700c1e67 2013-06-04 kinaba: cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } } 6b700c1e67 2013-06-04 kinaba: #define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock(); 6b700c1e67 2013-06-04 kinaba: #define END verify_case(_, EelAndRabbit().getmax(l, t));} 6b700c1e67 2013-06-04 kinaba: int main(){ 6b700c1e67 2013-06-04 kinaba: 6b700c1e67 2013-06-04 kinaba: CASE(0) 6b700c1e67 2013-06-04 kinaba: int l_[] = {2, 4, 3, 2, 2, 1, 10}; 6b700c1e67 2013-06-04 kinaba: vector <int> l(l_, l_+sizeof(l_)/sizeof(*l_)); 6b700c1e67 2013-06-04 kinaba: int t_[] = {2, 6, 3, 7, 0, 2, 0}; 6b700c1e67 2013-06-04 kinaba: vector <int> t(t_, t_+sizeof(t_)/sizeof(*t_)); 6b700c1e67 2013-06-04 kinaba: int _ = 6; 6b700c1e67 2013-06-04 kinaba: END 6b700c1e67 2013-06-04 kinaba: CASE(1) 6b700c1e67 2013-06-04 kinaba: int l_[] = {1, 1, 1}; 6b700c1e67 2013-06-04 kinaba: vector <int> l(l_, l_+sizeof(l_)/sizeof(*l_)); 6b700c1e67 2013-06-04 kinaba: int t_[] = {2, 0, 4}; 6b700c1e67 2013-06-04 kinaba: vector <int> t(t_, t_+sizeof(t_)/sizeof(*t_)); 6b700c1e67 2013-06-04 kinaba: int _ = 2; 6b700c1e67 2013-06-04 kinaba: END 6b700c1e67 2013-06-04 kinaba: CASE(2) 6b700c1e67 2013-06-04 kinaba: int l_[] = {1}; 6b700c1e67 2013-06-04 kinaba: vector <int> l(l_, l_+sizeof(l_)/sizeof(*l_)); 6b700c1e67 2013-06-04 kinaba: int t_[] = {1}; 6b700c1e67 2013-06-04 kinaba: vector <int> t(t_, t_+sizeof(t_)/sizeof(*t_)); 6b700c1e67 2013-06-04 kinaba: int _ = 1; 6b700c1e67 2013-06-04 kinaba: END 6b700c1e67 2013-06-04 kinaba: CASE(3) 6b700c1e67 2013-06-04 kinaba: int l_[] = {8, 2, 1, 10, 8, 6, 3, 1, 2, 5}; 6b700c1e67 2013-06-04 kinaba: vector <int> l(l_, l_+sizeof(l_)/sizeof(*l_)); 6b700c1e67 2013-06-04 kinaba: int t_[] = {17, 27, 26, 11, 1, 27, 23, 12, 11, 13}; 6b700c1e67 2013-06-04 kinaba: vector <int> t(t_, t_+sizeof(t_)/sizeof(*t_)); 6b700c1e67 2013-06-04 kinaba: int _ = 7; 6b700c1e67 2013-06-04 kinaba: END 6b700c1e67 2013-06-04 kinaba: /* 6b700c1e67 2013-06-04 kinaba: CASE(4) 6b700c1e67 2013-06-04 kinaba: int l_[] = ; 6b700c1e67 2013-06-04 kinaba: vector <int> l(l_, l_+sizeof(l_)/sizeof(*l_)); 6b700c1e67 2013-06-04 kinaba: int t_[] = ; 6b700c1e67 2013-06-04 kinaba: vector <int> t(t_, t_+sizeof(t_)/sizeof(*t_)); 6b700c1e67 2013-06-04 kinaba: int _ = ; 6b700c1e67 2013-06-04 kinaba: END 6b700c1e67 2013-06-04 kinaba: CASE(5) 6b700c1e67 2013-06-04 kinaba: int l_[] = ; 6b700c1e67 2013-06-04 kinaba: vector <int> l(l_, l_+sizeof(l_)/sizeof(*l_)); 6b700c1e67 2013-06-04 kinaba: int t_[] = ; 6b700c1e67 2013-06-04 kinaba: vector <int> t(t_, t_+sizeof(t_)/sizeof(*t_)); 6b700c1e67 2013-06-04 kinaba: int _ = ; 6b700c1e67 2013-06-04 kinaba: END 6b700c1e67 2013-06-04 kinaba: */ 6b700c1e67 2013-06-04 kinaba: } 6b700c1e67 2013-06-04 kinaba: // END CUT HERE