#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 BinPacking { public:
int minBins(vector <int> item)
{
sort(item.begin(), item.end());
return rec(item);
}
int rec(vector<int>& item)
{
if(item.empty())
return 0;
if(item.back() == 100)
return (item.size()+2)/3;
int w = item.back();
item.pop_back();
int i = -1;
for(int k=0; k<item.size(); ++k)
if(item[k] + w <= 300)
i = k;
if(i!=-1)
item.erase(item.begin() + i);
return 1 + rec(item);
}
};
// 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(_, BinPacking().minBins(item));}
int main(){
CASE(0)
int item_[] = {150, 150, 150, 150, 150};
vector <int> item(item_, item_+sizeof(item_)/sizeof(*item_));
int _ = 3;
END
CASE(1)
int item_[] = {130, 140, 150, 160};
vector <int> item(item_, item_+sizeof(item_)/sizeof(*item_));
int _ = 2;
END
CASE(2)
int item_[] = {100, 100, 100, 100, 100, 100, 100, 100, 100};
vector <int> item(item_, item_+sizeof(item_)/sizeof(*item_));
int _ = 3;
END
CASE(3)
int item_[] = {100, 200, 100, 100, 100, 100, 200, 100, 200};
vector <int> item(item_, item_+sizeof(item_)/sizeof(*item_));
int _ = 4;
END
CASE(4)
int item_[] = {157, 142, 167, 133, 135, 157, 143, 160, 141, 123, 162, 159, 165, 137, 138, 152};
vector <int> item(item_, item_+sizeof(item_)/sizeof(*item_));
int _ = 8;
END
/*
CASE(5)
int item_[] = ;
vector <int> item(item_, item_+sizeof(item_)/sizeof(*item_));
int _ = ;
END
CASE(6)
int item_[] = ;
vector <int> item(item_, item_+sizeof(item_)/sizeof(*item_));
int _ = ;
END
*/
}
// END CUT HERE