b57cc94f1b 2011-10-08 kinaba: #include <iostream> b57cc94f1b 2011-10-08 kinaba: #include <sstream> b57cc94f1b 2011-10-08 kinaba: #include <iomanip> b57cc94f1b 2011-10-08 kinaba: #include <vector> b57cc94f1b 2011-10-08 kinaba: #include <string> b57cc94f1b 2011-10-08 kinaba: #include <map> b57cc94f1b 2011-10-08 kinaba: #include <set> b57cc94f1b 2011-10-08 kinaba: #include <algorithm> b57cc94f1b 2011-10-08 kinaba: #include <numeric> b57cc94f1b 2011-10-08 kinaba: #include <iterator> b57cc94f1b 2011-10-08 kinaba: #include <functional> b57cc94f1b 2011-10-08 kinaba: #include <complex> b57cc94f1b 2011-10-08 kinaba: #include <queue> b57cc94f1b 2011-10-08 kinaba: #include <stack> b57cc94f1b 2011-10-08 kinaba: #include <cmath> b57cc94f1b 2011-10-08 kinaba: #include <cassert> b57cc94f1b 2011-10-08 kinaba: #include <cstring> b57cc94f1b 2011-10-08 kinaba: using namespace std; b57cc94f1b 2011-10-08 kinaba: typedef long long LL; b57cc94f1b 2011-10-08 kinaba: typedef complex<double> CMP; b57cc94f1b 2011-10-08 kinaba: b57cc94f1b 2011-10-08 kinaba: class ColorfulRabbits { public: b57cc94f1b 2011-10-08 kinaba: int getMinimum(vector <int> replies) b57cc94f1b 2011-10-08 kinaba: { b57cc94f1b 2011-10-08 kinaba: map<int,int> m; b57cc94f1b 2011-10-08 kinaba: for(int i=0; i<replies.size(); ++i) b57cc94f1b 2011-10-08 kinaba: m[replies[i]]++; b57cc94f1b 2011-10-08 kinaba: int total = 0; b57cc94f1b 2011-10-08 kinaba: for(map<int,int>::iterator it=m.begin(); it!=m.end(); ++it) b57cc94f1b 2011-10-08 kinaba: { b57cc94f1b 2011-10-08 kinaba: int s = it->first + 1; b57cc94f1b 2011-10-08 kinaba: int n = it->second; b57cc94f1b 2011-10-08 kinaba: total += (n+s-1) / s * s; b57cc94f1b 2011-10-08 kinaba: } b57cc94f1b 2011-10-08 kinaba: return total; b57cc94f1b 2011-10-08 kinaba: } b57cc94f1b 2011-10-08 kinaba: }; b57cc94f1b 2011-10-08 kinaba: b57cc94f1b 2011-10-08 kinaba: // BEGIN CUT HERE b57cc94f1b 2011-10-08 kinaba: #include <ctime> b57cc94f1b 2011-10-08 kinaba: double start_time; string timer() b57cc94f1b 2011-10-08 kinaba: { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); } b57cc94f1b 2011-10-08 kinaba: template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) b57cc94f1b 2011-10-08 kinaba: { os << "{ "; b57cc94f1b 2011-10-08 kinaba: for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it) b57cc94f1b 2011-10-08 kinaba: os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; } b57cc94f1b 2011-10-08 kinaba: void verify_case(const int& Expected, const int& Received) { b57cc94f1b 2011-10-08 kinaba: bool ok = (Expected == Received); b57cc94f1b 2011-10-08 kinaba: if(ok) cerr << "PASSED" << timer() << endl; else { cerr << "FAILED" << timer() << endl; b57cc94f1b 2011-10-08 kinaba: cerr << "\to: \"" << Expected << '\"' << endl << "\tx: \"" << Received << '\"' << endl; } } b57cc94f1b 2011-10-08 kinaba: #define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock(); b57cc94f1b 2011-10-08 kinaba: #define END verify_case(_, ColorfulRabbits().getMinimum(replies));} b57cc94f1b 2011-10-08 kinaba: int main(){ b57cc94f1b 2011-10-08 kinaba: b57cc94f1b 2011-10-08 kinaba: CASE(0) b57cc94f1b 2011-10-08 kinaba: int replies_[] = { 1, 1, 2, 2 } b57cc94f1b 2011-10-08 kinaba: ; b57cc94f1b 2011-10-08 kinaba: vector <int> replies(replies_, replies_+sizeof(replies_)/sizeof(*replies_)); b57cc94f1b 2011-10-08 kinaba: int _ = 5; b57cc94f1b 2011-10-08 kinaba: END b57cc94f1b 2011-10-08 kinaba: CASE(1) b57cc94f1b 2011-10-08 kinaba: int replies_[] = { 0 } b57cc94f1b 2011-10-08 kinaba: ; b57cc94f1b 2011-10-08 kinaba: vector <int> replies(replies_, replies_+sizeof(replies_)/sizeof(*replies_)); b57cc94f1b 2011-10-08 kinaba: int _ = 1; b57cc94f1b 2011-10-08 kinaba: END b57cc94f1b 2011-10-08 kinaba: CASE(2) b57cc94f1b 2011-10-08 kinaba: int replies_[] = { 2, 2, 44, 2, 2, 2, 444, 2, 2 } b57cc94f1b 2011-10-08 kinaba: ; b57cc94f1b 2011-10-08 kinaba: vector <int> replies(replies_, replies_+sizeof(replies_)/sizeof(*replies_)); b57cc94f1b 2011-10-08 kinaba: int _ = 499; b57cc94f1b 2011-10-08 kinaba: END b57cc94f1b 2011-10-08 kinaba: CASE(3) b57cc94f1b 2011-10-08 kinaba: int replies_[] = {1}; b57cc94f1b 2011-10-08 kinaba: vector <int> replies(replies_, replies_+sizeof(replies_)/sizeof(*replies_)); b57cc94f1b 2011-10-08 kinaba: int _ = 2; b57cc94f1b 2011-10-08 kinaba: END b57cc94f1b 2011-10-08 kinaba: CASE(4) b57cc94f1b 2011-10-08 kinaba: int replies_[] = {2}; b57cc94f1b 2011-10-08 kinaba: vector <int> replies(replies_, replies_+sizeof(replies_)/sizeof(*replies_)); b57cc94f1b 2011-10-08 kinaba: int _ = 3; b57cc94f1b 2011-10-08 kinaba: END b57cc94f1b 2011-10-08 kinaba: CASE(5) b57cc94f1b 2011-10-08 kinaba: int replies_[] = {1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000,1000000}; b57cc94f1b 2011-10-08 kinaba: vector <int> replies(replies_, replies_+sizeof(replies_)/sizeof(*replies_)); b57cc94f1b 2011-10-08 kinaba: int _ = -1; b57cc94f1b 2011-10-08 kinaba: END b57cc94f1b 2011-10-08 kinaba: b57cc94f1b 2011-10-08 kinaba: } b57cc94f1b 2011-10-08 kinaba: // END CUT HERE