db58c713f6 2012-02-24 kinaba: #include <iostream> db58c713f6 2012-02-24 kinaba: #include <sstream> db58c713f6 2012-02-24 kinaba: #include <iomanip> db58c713f6 2012-02-24 kinaba: #include <vector> db58c713f6 2012-02-24 kinaba: #include <string> db58c713f6 2012-02-24 kinaba: #include <map> db58c713f6 2012-02-24 kinaba: #include <set> db58c713f6 2012-02-24 kinaba: #include <algorithm> db58c713f6 2012-02-24 kinaba: #include <numeric> db58c713f6 2012-02-24 kinaba: #include <iterator> db58c713f6 2012-02-24 kinaba: #include <functional> db58c713f6 2012-02-24 kinaba: #include <complex> db58c713f6 2012-02-24 kinaba: #include <queue> db58c713f6 2012-02-24 kinaba: #include <stack> db58c713f6 2012-02-24 kinaba: #include <cmath> db58c713f6 2012-02-24 kinaba: #include <cassert> db58c713f6 2012-02-24 kinaba: #include <cstring> db58c713f6 2012-02-24 kinaba: #ifdef __GNUC__ db58c713f6 2012-02-24 kinaba: #include <ext/hash_map> db58c713f6 2012-02-24 kinaba: #define unordered_map __gnu_cxx::hash_map db58c713f6 2012-02-24 kinaba: #else db58c713f6 2012-02-24 kinaba: #include <unordered_map> db58c713f6 2012-02-24 kinaba: #endif db58c713f6 2012-02-24 kinaba: using namespace std; db58c713f6 2012-02-24 kinaba: typedef long long LL; db58c713f6 2012-02-24 kinaba: typedef complex<double> CMP; db58c713f6 2012-02-24 kinaba: db58c713f6 2012-02-24 kinaba: class DengklekTryingToSleep { public: db58c713f6 2012-02-24 kinaba: int minDucks(vector <int> ducks) db58c713f6 2012-02-24 kinaba: { db58c713f6 2012-02-24 kinaba: int A = *min_element(ducks.begin(), ducks.end()); db58c713f6 2012-02-24 kinaba: int B = *max_element(ducks.begin(), ducks.end()); db58c713f6 2012-02-24 kinaba: return (B-A+1) - ducks.size(); db58c713f6 2012-02-24 kinaba: } db58c713f6 2012-02-24 kinaba: }; db58c713f6 2012-02-24 kinaba: db58c713f6 2012-02-24 kinaba: // BEGIN CUT HERE db58c713f6 2012-02-24 kinaba: #include <ctime> db58c713f6 2012-02-24 kinaba: double start_time; string timer() db58c713f6 2012-02-24 kinaba: { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); } db58c713f6 2012-02-24 kinaba: template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) db58c713f6 2012-02-24 kinaba: { os << "{ "; db58c713f6 2012-02-24 kinaba: for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it) db58c713f6 2012-02-24 kinaba: os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; } db58c713f6 2012-02-24 kinaba: void verify_case(const int& Expected, const int& Received) { db58c713f6 2012-02-24 kinaba: bool ok = (Expected == Received); db58c713f6 2012-02-24 kinaba: if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl; db58c713f6 2012-02-24 kinaba: cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } } db58c713f6 2012-02-24 kinaba: #define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock(); db58c713f6 2012-02-24 kinaba: #define END verify_case(_, DengklekTryingToSleep().minDucks(ducks));} db58c713f6 2012-02-24 kinaba: int main(){ db58c713f6 2012-02-24 kinaba: db58c713f6 2012-02-24 kinaba: CASE(0) db58c713f6 2012-02-24 kinaba: int ducks_[] = {5, 3, 2}; db58c713f6 2012-02-24 kinaba: vector <int> ducks(ducks_, ducks_+sizeof(ducks_)/sizeof(*ducks_)); db58c713f6 2012-02-24 kinaba: int _ = 1; db58c713f6 2012-02-24 kinaba: END db58c713f6 2012-02-24 kinaba: CASE(1) db58c713f6 2012-02-24 kinaba: int ducks_[] = {58}; db58c713f6 2012-02-24 kinaba: vector <int> ducks(ducks_, ducks_+sizeof(ducks_)/sizeof(*ducks_)); db58c713f6 2012-02-24 kinaba: int _ = 0; db58c713f6 2012-02-24 kinaba: END db58c713f6 2012-02-24 kinaba: CASE(2) db58c713f6 2012-02-24 kinaba: int ducks_[] = {9, 3, 6, 4}; db58c713f6 2012-02-24 kinaba: vector <int> ducks(ducks_, ducks_+sizeof(ducks_)/sizeof(*ducks_)); db58c713f6 2012-02-24 kinaba: int _ = 3; db58c713f6 2012-02-24 kinaba: END db58c713f6 2012-02-24 kinaba: CASE(3) db58c713f6 2012-02-24 kinaba: int ducks_[] = {7, 4, 77, 47, 74, 44}; db58c713f6 2012-02-24 kinaba: vector <int> ducks(ducks_, ducks_+sizeof(ducks_)/sizeof(*ducks_)); db58c713f6 2012-02-24 kinaba: int _ = 68; db58c713f6 2012-02-24 kinaba: END db58c713f6 2012-02-24 kinaba: CASE(4) db58c713f6 2012-02-24 kinaba: int ducks_[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; db58c713f6 2012-02-24 kinaba: vector <int> ducks(ducks_, ducks_+sizeof(ducks_)/sizeof(*ducks_)); db58c713f6 2012-02-24 kinaba: int _ = 0; db58c713f6 2012-02-24 kinaba: END db58c713f6 2012-02-24 kinaba: /* db58c713f6 2012-02-24 kinaba: CASE(5) db58c713f6 2012-02-24 kinaba: int ducks_[] = ; db58c713f6 2012-02-24 kinaba: vector <int> ducks(ducks_, ducks_+sizeof(ducks_)/sizeof(*ducks_)); db58c713f6 2012-02-24 kinaba: int _ = ; db58c713f6 2012-02-24 kinaba: END db58c713f6 2012-02-24 kinaba: CASE(6) db58c713f6 2012-02-24 kinaba: int ducks_[] = ; db58c713f6 2012-02-24 kinaba: vector <int> ducks(ducks_, ducks_+sizeof(ducks_)/sizeof(*ducks_)); db58c713f6 2012-02-24 kinaba: int _ = ; db58c713f6 2012-02-24 kinaba: END db58c713f6 2012-02-24 kinaba: */ db58c713f6 2012-02-24 kinaba: } db58c713f6 2012-02-24 kinaba: // END CUT HERE