Artifact Content
Not logged in

Artifact 016b888673aa9f4bf8a953fcc98beb9bbdf864bb


#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 <tuple>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class DivisibleSetDiv1 { public:
	string isPossible(vector <int> b)
	{
		return solve(b) ? "Possible" : "Impossible";
	}

	bool solve(vector<int> b)
	{
		sort(b.begin(), b.end());
		int n = b.size();

		int sum = 0;
		for(int i=0; i<b.size(); ++i)
			sum += (n-i);
		for(int i=0; i<b.size(); ++i)
			if(sum > (b[i]+1)*(n-i))
				return false;
		return true;
	}
};

// 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 string& Expected, const string& 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(_, DivisibleSetDiv1().isPossible(b));}
int main(){

CASE(0)
	int b_[] = {2,1};
	  vector <int> b(b_, b_+sizeof(b_)/sizeof(*b_)); 
	string _ = "Possible"; 
END
CASE(1)
	int b_[] = {1,1};
	  vector <int> b(b_, b_+sizeof(b_)/sizeof(*b_)); 
	string _ = "Impossible"; 
END
CASE(2)
	int b_[] = {7, 7, 7};
	  vector <int> b(b_, b_+sizeof(b_)/sizeof(*b_)); 
	string _ = "Possible"; 
END
CASE(3)
	int b_[] = {5,3,5,4,6,1,3,7,9,6,2,5,4,1,1,9,6,10,10,6,10,7,7,8};
	  vector <int> b(b_, b_+sizeof(b_)/sizeof(*b_)); 
	string _ = "Impossible"; 
END
CASE(4)
	int b_[] = {2,3,4};
	  vector <int> b(b_, b_+sizeof(b_)/sizeof(*b_)); 
	string _ = "Possible"; 
END
/*
CASE(5)
	int b_[] = ;
	  vector <int> b(b_, b_+sizeof(b_)/sizeof(*b_)); 
	string _ = ; 
END
*/
}
// END CUT HERE