ADDED SRM/609-U/1A.cpp Index: SRM/609-U/1A.cpp ================================================================== --- SRM/609-U/1A.cpp +++ SRM/609-U/1A.cpp @@ -0,0 +1,79 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; +typedef long long LL; +typedef complex CMP; + +class MagicalStringDiv1 { public: + int getLongest(string S) + { + int best = 0; + for(int rBegin=0; rBegin'); + int r = count(S.begin()+rBegin, S.end(), '<'); + best = max(best, 2*min(l,r)); + } + return best; + } +}; + +// BEGIN CUT HERE +#include +double start_time; string timer() + { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); } +template ostream& operator<<(ostream& os, const vector& v) + { os << "{ "; + for(typename vector::const_iterator it=v.begin(); it!=v.end(); ++it) + os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; } +void verify_case(const int& Expected, const int& Received) { + bool ok = (Expected == Received); + if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl; + cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } } +#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock(); +#define END verify_case(_, MagicalStringDiv1().getLongest(S));} +int main(){ + +CASE(0) + string S = "<><><<>"; + int _ = 4; +END +CASE(1) + string S = ">>><<<"; + int _ = 6; +END +CASE(2) + string S = "<<<>>>"; + int _ = 0; +END +CASE(3) + string S = "<<<<><>>><>>><>><>><>>><<<<>><>>>>><<>>>>><><<<<>>"; + int _ = 24; +END +/* +CASE(4) + string S = ; + int _ = ; +END +CASE(5) + string S = ; + int _ = ; +END +*/ +} +// END CUT HERE ADDED SRM/609-U/1B.cpp Index: SRM/609-U/1B.cpp ================================================================== --- SRM/609-U/1B.cpp +++ SRM/609-U/1B.cpp @@ -0,0 +1,113 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; +typedef long long LL; +typedef complex CMP; + +class PackingBallsDiv1 { public: + int minPacks(int K, int A, int B, int C, int D) + { + vector X(K); + X[0] = A; + for(int i=1; i(best, base + X[i] + X.size()-i-1); + return best; + } +}; + +// BEGIN CUT HERE +#include +double start_time; string timer() + { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); } +template ostream& operator<<(ostream& os, const vector& v) + { os << "{ "; + for(typename vector::const_iterator it=v.begin(); it!=v.end(); ++it) + os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; } +void verify_case(const int& Expected, const int& Received) { + bool ok = (Expected == Received); + if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl; + cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } } +#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock(); +#define END verify_case(_, PackingBallsDiv1().minPacks(K, A, B, C, D));} +int main(){ + +CASE(0) + int K = 3; + int A = 4; + int B = 2; + int C = 5; + int D = 6; + int _ = 4; +END +CASE(1) + int K = 1; + int A = 58; + int B = 23; + int C = 39; + int D = 93; + int _ = 58; +END +CASE(2) + int K = 23; + int A = 10988; + int B = 5573; + int C = 4384; + int D = 100007; + int _ = 47743; +END +CASE(3) + int K = 100000; + int A = 123456789; + int B = 234567890; + int C = 345678901; + int D = 1000000000; + int _ = 331988732; +END +/* +CASE(4) + int K = ; + int A = ; + int B = ; + int C = ; + int D = ; + int _ = ; +END +CASE(5) + int K = ; + int A = ; + int B = ; + int C = ; + int D = ; + int _ = ; +END +*/ +} +// END CUT HERE