Artifact Content
Not logged in

Artifact 1b6c222f9c3582e7bf8556f33429d8f0c96d575f


#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <cstring>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class ColorfulRabbits { public:
	int getMinimum(vector <int> replies) 
	{
		map<int,int> m;
		for(int i=0; i<replies.size(); ++i)
			m[replies[i]]++;
		int total = 0;
		for(map<int,int>::iterator it=m.begin(); it!=m.end(); ++it)
		{
			int s = it->first + 1;
			int n = it->second;
			total += (n+s-1) / s * s;
		}
		return total;
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::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(_, ColorfulRabbits().getMinimum(replies));}
int main(){

CASE(0)
	int replies_[] = { 1, 1, 2, 2 }
;
	  vector <int> replies(replies_, replies_+sizeof(replies_)/sizeof(*replies_)); 
	int _ = 5; 
END
CASE(1)
	int replies_[] = { 0 }
;
	  vector <int> replies(replies_, replies_+sizeof(replies_)/sizeof(*replies_)); 
	int _ = 1; 
END
CASE(2)
	int replies_[] = { 2, 2, 44, 2, 2, 2, 444, 2, 2 }
;
	  vector <int> replies(replies_, replies_+sizeof(replies_)/sizeof(*replies_)); 
	int _ = 499; 
END
CASE(3)
	int replies_[] = {1};
	  vector <int> replies(replies_, replies_+sizeof(replies_)/sizeof(*replies_)); 
	int _ = 2; 
END
CASE(4)
	int replies_[] = {2};
	  vector <int> replies(replies_, replies_+sizeof(replies_)/sizeof(*replies_)); 
	int _ = 3; 
END
CASE(5)
	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};
	  vector <int> replies(replies_, replies_+sizeof(replies_)/sizeof(*replies_)); 
	int _ = -1; 
END

}
// END CUT HERE