Artifact 0f86d3bb71a9b2cc29a472c6a04f7854532af4de
#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 MysteriousRestaurant { public:
int maxDays(vector <string> prices, int budget)
{
for(int D=prices.size(); D>=0; --D)
if( ok(D, prices, budget) )
return D;
return 0;
}
bool ok(int D, const vector<string>& prices, int budget)
{
int M = prices[0].size();
vector< vector<int> > p(7, vector<int>(M));
for(int i=0; i<D; ++i)
for(int m=0; m<M; ++m)
p[i%7][m] += toPrice(prices[i][m]);
int cost = 0;
for(int i=0; i<7; ++i)
{
int least = 0x7fffffff;
for(int m=0; m<M; ++m)
least = min(least, p[i][m]);
cost += least;
}
return cost <= budget;
}
int toPrice(char c)
{
if(c<='9')
return c-'0';
if(c<='Z')
return c-'A'+10;
return c-'a'+36;
}
};
// 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(_, MysteriousRestaurant().maxDays(prices, budget));}
int main(){
CASE(0)
string prices_[] = {"26", "14", "72", "39", "32", "85", "06"};
vector <string> prices(prices_, prices_+sizeof(prices_)/sizeof(*prices_));
int budget = 13;
int _ = 5;
END
CASE(1)
string prices_[] = {"26", "14", "72", "39", "32", "85", "06", "91"};
vector <string> prices(prices_, prices_+sizeof(prices_)/sizeof(*prices_));
int budget = 20;
int _ = 8;
END
CASE(2)
string prices_[] = {"SRM", "512"};
vector <string> prices(prices_, prices_+sizeof(prices_)/sizeof(*prices_));
int budget = 4;
int _ = 0;
END
CASE(3)
string prices_[] = {"Dear", "Code", "rsHa", "veFu", "nInT", "heCh", "alle", "ngeP", "hase", "andb", "ecar", "eful"};
vector <string> prices(prices_, prices_+sizeof(prices_)/sizeof(*prices_));
int budget = 256;
int _ = 10;
END
/*
CASE(4)
string prices_[] = ;
vector <string> prices(prices_, prices_+sizeof(prices_)/sizeof(*prices_));
int budget = ;
int _ = ;
END
CASE(5)
string prices_[] = ;
vector <string> prices(prices_, prices_+sizeof(prices_)/sizeof(*prices_));
int budget = ;
int _ = ;
END
*/
}
// END CUT HERE